From dd8e62ac1ebd82d2679f27e84d0f6d734af9c7bb Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 18 Jun 2024 15:11:15 -0700 Subject: [PATCH] Add explicit template instantiations to fix MSVC compilation errors --- .../i18n/unicode/messageformat2_formattable.h | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/icu4c/source/i18n/unicode/messageformat2_formattable.h b/icu4c/source/i18n/unicode/messageformat2_formattable.h index d99260e952f9..7b160ef5f702 100644 --- a/icu4c/source/i18n/unicode/messageformat2_formattable.h +++ b/icu4c/source/i18n/unicode/messageformat2_formattable.h @@ -437,7 +437,24 @@ namespace message2 { }; // class Formattable class FunctionOptions; +} // namespace message2 +/// @cond DOXYGEN_IGNORE +// Export an explicit template instantiation of the LocalPointer that is used as a +// data member of various MFDataModel classes. +// (When building DLLs for Windows this is required.) +// (See measunit_impl.h, datefmt.h, collationiterator.h, erarules.h and others +// for similar examples.) +#if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN +template class U_I18N_API LocalPointerBase; +template class U_I18N_API LocalArray; +#endif +#if defined(U_REAL_MSVC) +#pragma warning(pop) +#endif +/// @endcond + +namespace message2 { /** * The `FormattableWithOptions` class represents a typed value that has a map * of resolved options attached to it. If the map is non-empty, then this value @@ -719,7 +736,27 @@ class U_I18N_API ResolvedFunctionOption : public UObject { }; // class FormattedValue class FunctionOptions; +} // namespace message2 +/// @cond DOXYGEN_IGNORE +// Export an explicit template instantiation of the LocalPointer that is used as a +// data member of various MFDataModel classes. +// (When building DLLs for Windows this is required.) +// (See measunit_impl.h, datefmt.h, collationiterator.h, erarules.h and others +// for similar examples.) +#if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN +template class U_I18N_API std::optional; +template class U_I18N_API std::optional; +template class U_I18N_API std::optional; +template class U_I18N_API LocalPointerBase; +template class U_I18N_API LocalArray; +#endif +#if defined(U_REAL_MSVC) +#pragma warning(pop) +#endif +/// @endcond + +namespace message2 { /** * A `FormattablePlaceholder` encapsulates an input value (a `message2::FormattableWithOptions`) * together with an optional output value (a `message2::FormattedValue`).