From fc56af14c2f60e6e7f83a5fe4eb064eb0d1d6806 Mon Sep 17 00:00:00 2001 From: Alexey Ochapov Date: Sun, 18 Apr 2021 08:06:22 +0300 Subject: [PATCH] move fixed_string from compile.h to format.h --- include/fmt/compile.h | 17 ----------------- include/fmt/format.h | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/include/fmt/compile.h b/include/fmt/compile.h index 12f203b2..b83f3167 100644 --- a/include/fmt/compile.h +++ b/include/fmt/compile.h @@ -13,15 +13,6 @@ #include "format.h" -#ifndef FMT_USE_NONTYPE_TEMPLATE_PARAMETERS -# if defined(__cpp_nontype_template_parameter_class) && \ - (!FMT_GCC_VERSION || FMT_GCC_VERSION >= 903) -# define FMT_USE_NONTYPE_TEMPLATE_PARAMETERS 1 -# else -# define FMT_USE_NONTYPE_TEMPLATE_PARAMETERS 0 -# endif -#endif - FMT_BEGIN_NAMESPACE namespace detail { @@ -126,14 +117,6 @@ struct is_compiled_string : std::is_base_of {}; #define FMT_COMPILE(s) FMT_STRING_IMPL(s, fmt::detail::compiled_string) #if FMT_USE_NONTYPE_TEMPLATE_PARAMETERS -template struct fixed_string { - constexpr fixed_string(const Char (&str)[N]) { - copy_str(static_cast(str), str + N, - data); - } - Char data[N]{}; -}; - template Str> struct udl_compiled_string : compiled_string { using char_type = Char; diff --git a/include/fmt/format.h b/include/fmt/format.h index 95db108f..be079b66 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -263,6 +263,15 @@ inline int ctzll(uint64_t x) { FMT_END_NAMESPACE #endif +#ifndef FMT_USE_NONTYPE_TEMPLATE_PARAMETERS +# if defined(__cpp_nontype_template_parameter_class) && \ + (!FMT_GCC_VERSION || FMT_GCC_VERSION >= 903) +# define FMT_USE_NONTYPE_TEMPLATE_PARAMETERS 1 +# else +# define FMT_USE_NONTYPE_TEMPLATE_PARAMETERS 0 +# endif +#endif + FMT_BEGIN_NAMESPACE namespace detail { @@ -3908,6 +3917,19 @@ void vprint(basic_string_view format_str, wformat_args args) { } FMT_MODULE_EXPORT_END + +#if FMT_USE_NONTYPE_TEMPLATE_PARAMETERS +namespace detail { +template struct fixed_string { + constexpr fixed_string(const Char (&str)[N]) { + copy_str(static_cast(str), str + N, + data); + } + Char data[N]{}; +}; +} // namespace detail +#endif + #if FMT_USE_USER_DEFINED_LITERALS namespace detail { template struct udl_formatter {