]> granicus.if.org Git - icu/commitdiff
ICU-13725 Fix last remaining C4251 warnings/errors by bringing back the CurrencyPlura...
authorJeff Genovy <29107334+jefgen@users.noreply.github.com>
Wed, 2 May 2018 08:18:00 +0000 (08:18 +0000)
committerJeff Genovy <29107334+jefgen@users.noreply.github.com>
Wed, 2 May 2018 08:18:00 +0000 (08:18 +0000)
X-SVN-Rev: 41308

icu4c/source/i18n/number_decimfmtprops.h

index 05788dbe36369367263f415ff632db5fb78b7e7e..4a78ed1b9b8d7066eeb45e44653ab96b6e8db7b2 100644 (file)
@@ -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<CurrencyPluralInfo>;
 template class U_I18N_API LocalPointer<CurrencyPluralInfo>;
 #endif
 
-// Exported as U_I18N_API because it is a public member field of exported DecimalFormatProperties
-template<typename T>
-struct U_I18N_API CopyableLocalPointer {
-    LocalPointer<T> fPtr;
-
-    CopyableLocalPointer() = default;
-
-    CopyableLocalPointer(const CopyableLocalPointer& other) {
-        if (!other.fPtr.isNull()) {
-            fPtr.adoptInstead(new T(*other.fPtr));
-        }
-    }
+namespace number {
+namespace impl {
 
-    CopyableLocalPointer& operator=(const CopyableLocalPointer& other) {
-        if (!other.fPtr.isNull()) {
-            fPtr.adoptInstead(new T(*other.fPtr));
-        }
-        return *this;
-    }
+// Exported as U_I18N_API because it is a public member field of exported DecimalFormatProperties
+// 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<CurrencyPluralInfo> fPtr;
+
+       CurrencyPluralInfoWrapper() = default;
+
+       CurrencyPluralInfoWrapper(const CurrencyPluralInfoWrapper& other) {
+               if (!other.fPtr.isNull()) {
+                       fPtr.adoptInstead(new CurrencyPluralInfo(*other.fPtr));
+               }
+       }
+
+       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<UNumberCompactStyle> compactStyle;
     NullableValue<CurrencyUnit> currency;
-    CopyableLocalPointer<CurrencyPluralInfo> currencyPluralInfo;
+       CurrencyPluralInfoWrapper currencyPluralInfo;
     NullableValue<UCurrencyUsage> currencyUsage;
     bool decimalPatternMatchRequired;
     bool decimalSeparatorAlwaysShown;