@@ -2314,6 +2314,15 @@ template <typename T, typename Char, type TYPE> struct native_formatter {
23142314 -> decltype(ctx.out());
23152315};
23162316
2317+ template <bool B> constexpr bool enforce_compile_checks () {
2318+ #ifdef FMT_ENFORCE_COMPILE_STRING
2319+ static_assert (
2320+ FMT_USE_CONSTEVAL && B,
2321+ " FMT_ENFORCE_COMPILE_STRING requires format strings to use FMT_STRING" );
2322+ #endif
2323+ return true ;
2324+ }
2325+
23172326template <typename T = int > constexpr auto is_locking () -> bool {
23182327 return locking<remove_cvref_t <T>>::value;
23192328}
@@ -2630,23 +2639,17 @@ template <typename... T> struct fstring {
26302639 std::is_reference<T>::value)...>() == 0 ,
26312640 " passing views as lvalues is disallowed" );
26322641 if (FMT_USE_CONSTEVAL) parse_format_string<char >(s, checker (s, arg_pack ()));
2633- #ifdef FMT_ENFORCE_COMPILE_STRING
2634- static_assert (
2635- FMT_USE_CONSTEVAL && sizeof (s) != 0 ,
2636- " FMT_ENFORCE_COMPILE_STRING requires format strings to use FMT_STRING" );
2637- #endif
2642+ constexpr bool unused = detail::enforce_compile_checks<sizeof (s) != 0 >();
2643+ (void )unused;
26382644 }
26392645 template <typename S,
26402646 FMT_ENABLE_IF (std::is_convertible<const S&, string_view>::value)>
26412647 FMT_CONSTEVAL FMT_ALWAYS_INLINE fstring(const S& s) : str(s) {
26422648 auto sv = string_view (str);
26432649 if (FMT_USE_CONSTEVAL)
26442650 detail::parse_format_string<char >(sv, checker (sv, arg_pack ()));
2645- #ifdef FMT_ENFORCE_COMPILE_STRING
2646- static_assert (
2647- FMT_USE_CONSTEVAL && sizeof (s) != 0 ,
2648- " FMT_ENFORCE_COMPILE_STRING requires format strings to use FMT_STRING" );
2649- #endif
2651+ constexpr bool unused = detail::enforce_compile_checks<sizeof (s) != 0 >();
2652+ (void )unused;
26502653 }
26512654 template <typename S,
26522655 FMT_ENABLE_IF (std::is_base_of<detail::compile_string, S>::value&&
0 commit comments