Skip to content

Commit

Permalink
Add explicit template instantiations to fix MSVC compilation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
catamorphism committed Jun 18, 2024
1 parent 53c40c9 commit dd8e62a
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions icu4c/source/i18n/unicode/messageformat2_formattable.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<icu::message2::FunctionOptions>;
template class U_I18N_API LocalArray<icu::message2::FunctionOptions>;
#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
Expand Down Expand Up @@ -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<icu::UnicodeString>;
template class U_I18N_API std::optional<icu::message2::FormattableWithOptions>;
template class U_I18N_API std::optional<icu::message2::FormattedValue>;
template class U_I18N_API LocalPointerBase<icu::message2::ResolvedFunctionOption>;
template class U_I18N_API LocalArray<icu::message2::ResolvedFunctionOption>;
#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`).
Expand Down

0 comments on commit dd8e62a

Please sign in to comment.