facet_id.hpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. //
  2. // Copyright (c) 2022-2023 Alexander Grund
  3. //
  4. // Distributed under the Boost Software License, Version 1.0.
  5. // https://www.boost.org/LICENSE_1_0.txt
  6. #ifndef BOOST_LOCALE_DETAIL_FACET_ID_HPP_INCLUDED
  7. #define BOOST_LOCALE_DETAIL_FACET_ID_HPP_INCLUDED
  8. #include <boost/locale/config.hpp>
  9. #include <locale>
  10. /// \cond INTERNAL
  11. namespace boost { namespace locale { namespace detail {
  12. #if BOOST_CLANG_VERSION >= 40900
  13. # pragma clang diagnostic push
  14. # pragma clang diagnostic ignored "-Wundefined-var-template"
  15. #endif
  16. /// CRTP base class to hold the id required for facets
  17. ///
  18. /// Required because the id needs to be defined in a CPP file and hence ex/imported for shared libraries.
  19. /// However the virtual classes need to be declared as BOOST_VISIBLE to combine the VTables because otherwise
  20. /// casts/virtual-calls might be flagged as invalid by UBSAN
  21. template<class Derived>
  22. struct BOOST_LOCALE_DECL facet_id {
  23. static std::locale::id id;
  24. };
  25. #if BOOST_CLANG_VERSION >= 40900
  26. # pragma clang diagnostic pop
  27. #endif
  28. }}} // namespace boost::locale::detail
  29. /// \endcond
  30. #endif