From 6f4dcfaa641018029cb5e32c924a1127e2231de9 Mon Sep 17 00:00:00 2001 From: Leander Schulten Date: Wed, 19 Nov 2025 19:55:24 +0100 Subject: [PATCH] Don't use static to mark constexpr variables as link lokal Otherwise it is impossible to export types that depend on the strong_type since some of the used templated values are link lokal. Error message from gcc: out/build/x64-debug-linux/vcpkg_installed/x64-linux/include/strong_type/type.hpp:235:23: note: 'template constexpr const bool strong::impl::always_false< ...>' declared with internal linkage 235 | static constexpr bool always_false = false; | ^~~~~~~~~~~~ for something like ```c++ module; #include export module test; import std; using myint = strong::type; ``` with gcc 15.2 --- include/strong_type/type.hpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/include/strong_type/type.hpp b/include/strong_type/type.hpp index eabaf70..a3bb467 100644 --- a/include/strong_type/type.hpp +++ b/include/strong_type/type.hpp @@ -38,7 +38,7 @@ namespace strong { struct uninitialized_t { }; -static constexpr uninitialized_t uninitialized{}; +constexpr uninitialized_t uninitialized{}; template using modifier = typename M::template modifier; @@ -236,7 +236,7 @@ struct require_move_assignable }; template -static constexpr bool always_false = false; +constexpr bool always_false = false; template struct valid_type; template <> @@ -247,11 +247,10 @@ using void_t = void; template -static constexpr bool modifier_is +constexpr bool modifier_is = std::is_base_of, modifier>::value; template -static constexpr bool type_implements @@ -264,7 +263,6 @@ template < typename Type, typename ... Ms > -static constexpr bool modifier_is> @@ -276,7 +274,6 @@ template < typename Type, typename ... Haystack > -static constexpr bool type_implements, Type, Modifier> = (modifier_is, Type, Modifier> && ...); @@ -339,15 +336,15 @@ type_implements, Type, Modifier> #endif template -static constexpr bool type_is = false; +constexpr bool type_is = false; #if __cplusplus >= 201703L template -static constexpr bool type_is, M> +constexpr bool type_is, M> = (impl::type_implements, Ms> || ...); #else template -static constexpr bool type_is, M> +constexpr bool type_is, M> = impl::disjunction, Ms>>...>::value; #endif @@ -359,7 +356,7 @@ using get_strong = decltype(get_strong_(static_cast(nullptr))); } template -static constexpr bool type_is_v = impl::type_is, M>; +constexpr bool type_is_v = impl::type_is, M>; template using type_is = std::integral_constant>;