From 2d5e369e783733e1016731cec30c2f606acae83a Mon Sep 17 00:00:00 2001 From: Jeff Genovy <29107334+jefgen@users.noreply.github.com> Date: Wed, 2 May 2018 08:18:00 +0000 Subject: [PATCH] ICU-13725 Fix last remaining C4251 warnings/errors by bringing back the CurrencyPluralInfoWrapper. X-SVN-Rev: 41308 --- icu4c/source/i18n/number_decimfmtprops.h | 40 +++++++++++++----------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/icu4c/source/i18n/number_decimfmtprops.h b/icu4c/source/i18n/number_decimfmtprops.h index 05788dbe363..4a78ed1b9b8 100644 --- a/icu4c/source/i18n/number_decimfmtprops.h +++ b/icu4c/source/i18n/number_decimfmtprops.h @@ -17,9 +17,6 @@ U_NAMESPACE_BEGIN -namespace number { -namespace impl { - // Export an explicit template instantiation of the LocalPointer that is used as a // data member of CurrencyPluralInfoWrapper. // (When building DLLs for Windows this is required.) @@ -30,25 +27,30 @@ template class U_I18N_API LocalPointerBase; template class U_I18N_API LocalPointer; #endif +namespace number { +namespace impl { + // Exported as U_I18N_API because it is a public member field of exported DecimalFormatProperties -template -struct U_I18N_API CopyableLocalPointer { - LocalPointer fPtr; +// Using this wrapper is rather unfortunate, but is needed on Windows platforms in order to allow +// for DLL-exporting an fully specified template instantiation. +class U_I18N_API CurrencyPluralInfoWrapper { +public: + LocalPointer fPtr; - CopyableLocalPointer() = default; + CurrencyPluralInfoWrapper() = default; - CopyableLocalPointer(const CopyableLocalPointer& other) { - if (!other.fPtr.isNull()) { - fPtr.adoptInstead(new T(*other.fPtr)); - } - } + CurrencyPluralInfoWrapper(const CurrencyPluralInfoWrapper& other) { + if (!other.fPtr.isNull()) { + fPtr.adoptInstead(new CurrencyPluralInfo(*other.fPtr)); + } + } - CopyableLocalPointer& operator=(const CopyableLocalPointer& other) { - if (!other.fPtr.isNull()) { - fPtr.adoptInstead(new T(*other.fPtr)); - } - return *this; - } + CurrencyPluralInfoWrapper& operator=(const CurrencyPluralInfoWrapper& other) { + if (!other.fPtr.isNull()) { + fPtr.adoptInstead(new CurrencyPluralInfo(*other.fPtr)); + } + return *this; + } }; /** Controls the set of rules for parsing a string from the old DecimalFormat API. */ @@ -91,7 +93,7 @@ struct U_I18N_API DecimalFormatProperties { public: NullableValue compactStyle; NullableValue currency; - CopyableLocalPointer currencyPluralInfo; + CurrencyPluralInfoWrapper currencyPluralInfo; NullableValue currencyUsage; bool decimalPatternMatchRequired; bool decimalSeparatorAlwaysShown;