From 3d0bf4b9c70f0a559c822f1c31c62d71af6b5fbc Mon Sep 17 00:00:00 2001 From: Shane Carr Date: Wed, 2 May 2018 03:49:35 +0000 Subject: [PATCH] ICU-13644 Replying to review feedback. Changing enum methods on NumberFormatter to take by value instead of const reference. X-SVN-Rev: 41304 --- icu4c/source/i18n/number_fluent.cpp | 46 ++++++++++----------- icu4c/source/i18n/unicode/numberformatter.h | 16 +++---- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/icu4c/source/i18n/number_fluent.cpp b/icu4c/source/i18n/number_fluent.cpp index c92c6bd0be7..cea4125ae10 100644 --- a/icu4c/source/i18n/number_fluent.cpp +++ b/icu4c/source/i18n/number_fluent.cpp @@ -86,26 +86,14 @@ Derived NumberFormatterSettings::perUnit(const icu::MeasureUnit& perUni template Derived NumberFormatterSettings::perUnit(const icu::MeasureUnit& perUnit)&& { - Derived copy(*this); - // See comments above about slicing. - copy.fMacros.perUnit = perUnit; - return copy; -} - -template -Derived NumberFormatterSettings::adoptPerUnit(icu::MeasureUnit* perUnit) const& { Derived move(std::move(*this)); - // See comments above about slicing and ownership. - if (perUnit != nullptr) { - // TODO: On nullptr, reset to default value? - move.fMacros.perUnit = std::move(*perUnit); - delete perUnit; - } + // See comments above about slicing. + move.fMacros.perUnit = perUnit; return move; } template -Derived NumberFormatterSettings::adoptPerUnit(icu::MeasureUnit* perUnit)&& { +Derived NumberFormatterSettings::adoptPerUnit(icu::MeasureUnit* perUnit) const& { Derived copy(*this); // See comments above about slicing and ownership. if (perUnit != nullptr) { @@ -116,6 +104,18 @@ Derived NumberFormatterSettings::adoptPerUnit(icu::MeasureUnit* perUnit return copy; } +template +Derived NumberFormatterSettings::adoptPerUnit(icu::MeasureUnit* perUnit)&& { + Derived move(std::move(*this)); + // See comments above about slicing and ownership. + if (perUnit != nullptr) { + // TODO: On nullptr, reset to default value? + move.fMacros.perUnit = std::move(*perUnit); + delete perUnit; + } + return move; +} + template Derived NumberFormatterSettings::rounding(const Rounder& rounder) const& { Derived copy(*this); @@ -133,7 +133,7 @@ Derived NumberFormatterSettings::rounding(const Rounder& rounder)&& { } template -Derived NumberFormatterSettings::grouping(const UGroupingStrategy& strategy) const& { +Derived NumberFormatterSettings::grouping(UGroupingStrategy strategy) const& { Derived copy(*this); // NOTE: This is slightly different than how the setting is stored in Java // because we want to put it on the stack. @@ -142,7 +142,7 @@ Derived NumberFormatterSettings::grouping(const UGroupingStrategy& stra } template -Derived NumberFormatterSettings::grouping(const UGroupingStrategy& strategy)&& { +Derived NumberFormatterSettings::grouping(UGroupingStrategy strategy)&& { Derived move(std::move(*this)); move.fMacros.grouper = Grouper::forStrategy(strategy); return move; @@ -191,42 +191,42 @@ Derived NumberFormatterSettings::adoptSymbols(NumberingSystem* ns)&& { } template -Derived NumberFormatterSettings::unitWidth(const UNumberUnitWidth& width) const& { +Derived NumberFormatterSettings::unitWidth(UNumberUnitWidth width) const& { Derived copy(*this); copy.fMacros.unitWidth = width; return copy; } template -Derived NumberFormatterSettings::unitWidth(const UNumberUnitWidth& width)&& { +Derived NumberFormatterSettings::unitWidth(UNumberUnitWidth width)&& { Derived move(std::move(*this)); move.fMacros.unitWidth = width; return move; } template -Derived NumberFormatterSettings::sign(const UNumberSignDisplay& style) const& { +Derived NumberFormatterSettings::sign(UNumberSignDisplay style) const& { Derived copy(*this); copy.fMacros.sign = style; return copy; } template -Derived NumberFormatterSettings::sign(const UNumberSignDisplay& style)&& { +Derived NumberFormatterSettings::sign(UNumberSignDisplay style)&& { Derived move(std::move(*this)); move.fMacros.sign = style; return move; } template -Derived NumberFormatterSettings::decimal(const UNumberDecimalSeparatorDisplay& style) const& { +Derived NumberFormatterSettings::decimal(UNumberDecimalSeparatorDisplay style) const& { Derived copy(*this); copy.fMacros.decimal = style; return copy; } template -Derived NumberFormatterSettings::decimal(const UNumberDecimalSeparatorDisplay& style)&& { +Derived NumberFormatterSettings::decimal(UNumberDecimalSeparatorDisplay style)&& { Derived move(std::move(*this)); move.fMacros.decimal = style; return move; diff --git a/icu4c/source/i18n/unicode/numberformatter.h b/icu4c/source/i18n/unicode/numberformatter.h index 493051eb74f..9176ffaf954 100644 --- a/icu4c/source/i18n/unicode/numberformatter.h +++ b/icu4c/source/i18n/unicode/numberformatter.h @@ -1671,7 +1671,7 @@ class U_I18N_API NumberFormatterSettings { * @return The fluent chain. * @draft ICU 61 */ - Derived grouping(const UGroupingStrategy &strategy) const &; + Derived grouping(UGroupingStrategy strategy) const &; /** * Overload of grouping() for use on an rvalue reference. @@ -1683,7 +1683,7 @@ class U_I18N_API NumberFormatterSettings { * @provisional This API might change or be removed in a future release. * @draft ICU 62 */ - Derived grouping(const UGroupingStrategy& strategy) &&; + Derived grouping(UGroupingStrategy strategy) &&; /** * Specifies the minimum and maximum number of digits to render before the decimal mark. @@ -1846,7 +1846,7 @@ class U_I18N_API NumberFormatterSettings { * @see UNumberUnitWidth * @draft ICU 60 */ - Derived unitWidth(const UNumberUnitWidth &width) const &; + Derived unitWidth(UNumberUnitWidth width) const &; /** * Overload of unitWidth() for use on an rvalue reference. @@ -1857,7 +1857,7 @@ class U_I18N_API NumberFormatterSettings { * @see #unitWidth * @draft ICU 62 */ - Derived unitWidth(const UNumberUnitWidth &width) &&; + Derived unitWidth(UNumberUnitWidth width) &&; /** * Sets the plus/minus sign display strategy. Most common values: @@ -1885,7 +1885,7 @@ class U_I18N_API NumberFormatterSettings { * @provisional This API might change or be removed in a future release. * @draft ICU 60 */ - Derived sign(const UNumberSignDisplay &style) const &; + Derived sign(UNumberSignDisplay style) const &; /** * Overload of sign() for use on an rvalue reference. @@ -1896,7 +1896,7 @@ class U_I18N_API NumberFormatterSettings { * @see #sign * @draft ICU 62 */ - Derived sign(const UNumberSignDisplay &style) &&; + Derived sign(UNumberSignDisplay style) &&; /** * Sets the decimal separator display strategy. This affects integer numbers with no fraction part. Most common @@ -1924,7 +1924,7 @@ class U_I18N_API NumberFormatterSettings { * @provisional This API might change or be removed in a future release. * @draft ICU 60 */ - Derived decimal(const UNumberDecimalSeparatorDisplay &style) const &; + Derived decimal(UNumberDecimalSeparatorDisplay style) const &; /** * Overload of decimal() for use on an rvalue reference. @@ -1935,7 +1935,7 @@ class U_I18N_API NumberFormatterSettings { * @see #decimal * @draft ICU 62 */ - Derived decimal(const UNumberDecimalSeparatorDisplay &style) &&; + Derived decimal(UNumberDecimalSeparatorDisplay style) &&; /** * Sets a scale (multiplier) to be used to scale the number by an arbitrary amount before formatting.