From ba433e9fe9dcdde8965d78a71d9f70cdda74b702 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Fri, 21 Apr 2023 16:16:35 +0200 Subject: [PATCH] Use template structs to fix ODR violations --- include/boost/charconv/detail/dragonbox.hpp | 25 ++++++++++++--------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/include/boost/charconv/detail/dragonbox.hpp b/include/boost/charconv/detail/dragonbox.hpp index 2003ba8..df96bce 100644 --- a/include/boost/charconv/detail/dragonbox.hpp +++ b/include/boost/charconv/detail/dragonbox.hpp @@ -484,7 +484,8 @@ using signed_decimal_fp = decimal_fp; // Computed cache entries. //////////////////////////////////////////////////////////////////////////////////////// -struct cache_holder_ieee754_binary32 +template +struct cache_holder_ieee754_binary32_impl { using cache_entry_type = std::uint64_t; static constexpr int cache_bits = 64; @@ -515,14 +516,17 @@ struct cache_holder_ieee754_binary32 #if defined(BOOST_NO_CXX17_INLINE_VARIABLES) && (!defined(_MSC_VER) || _MSC_VER != 1900) -constexpr int cache_holder_ieee754_binary32::cache_bits; -constexpr int cache_holder_ieee754_binary32::min_k; -constexpr int cache_holder_ieee754_binary32::max_k; -constexpr typename cache_holder_ieee754_binary32::cache_entry_type cache_holder_ieee754_binary32::cache[]; +template constexpr int cache_holder_ieee754_binary32_impl::cache_bits; +template constexpr int cache_holder_ieee754_binary32_impl::min_k; +template constexpr int cache_holder_ieee754_binary32_impl::max_k; +template constexpr typename cache_holder_ieee754_binary32_impl::cache_entry_type cache_holder_ieee754_binary32_impl::cache[]; #endif -struct cache_holder_ieee754_binary64 +using cache_holder_ieee754_binary32 = cache_holder_ieee754_binary32_impl; + +template +struct cache_holder_ieee754_binary64_impl { using cache_entry_type = uint128; static constexpr int cache_bits = 128; @@ -843,13 +847,14 @@ struct cache_holder_ieee754_binary64 #if defined(BOOST_NO_CXX17_INLINE_VARIABLES) && (!defined(_MSC_VER) || _MSC_VER != 1900) -constexpr int cache_holder_ieee754_binary64::cache_bits; -constexpr int cache_holder_ieee754_binary64::min_k; -constexpr int cache_holder_ieee754_binary64::max_k; -constexpr typename cache_holder_ieee754_binary64::cache_entry_type cache_holder_ieee754_binary64::cache[]; +template constexpr int cache_holder_ieee754_binary64_impl::cache_bits; +template constexpr int cache_holder_ieee754_binary64_impl::min_k; +template constexpr int cache_holder_ieee754_binary64_impl::max_k; +template constexpr typename cache_holder_ieee754_binary64_impl::cache_entry_type cache_holder_ieee754_binary64_impl::cache[]; #endif +using cache_holder_ieee754_binary64 = cache_holder_ieee754_binary64_impl; //////////////////////////////////////////////////////////////////////////////////////// // Policies.