From b81bf00c9bd34da0c2eefb0a9371155f68740589 Mon Sep 17 00:00:00 2001 From: Alexey Ochapov Date: Mon, 7 Dec 2020 22:35:54 +0300 Subject: [PATCH] update FMT_USE_NONTYPE_TEMPLATE_PARAMETERS --- include/fmt/compile.h | 15 +++++++++------ test/compile-test.cc | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/include/fmt/compile.h b/include/fmt/compile.h index 8b1e3719..1332eb21 100644 --- a/include/fmt/compile.h +++ b/include/fmt/compile.h @@ -13,10 +13,13 @@ #include "format.h" -#if !defined(FMT_USE_NONTYPE_TEMPLATE_PARAMETERS) && \ - defined(__cpp_nontype_template_parameter_class) && \ - (!FMT_GCC_VERSION || FMT_GCC_VERSION >= 903) -# define FMT_USE_NONTYPE_TEMPLATE_PARAMETERS +#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 @@ -43,7 +46,7 @@ struct is_compiled_string : std::is_base_of {}; */ #define FMT_COMPILE(s) FMT_STRING_IMPL(s, fmt::detail::compiled_string) -#ifdef FMT_USE_NONTYPE_TEMPLATE_PARAMETERS +#if FMT_USE_NONTYPE_TEMPLATE_PARAMETERS template struct fixed_string { constexpr fixed_string(const Char (&str)[N]) { copy_str(static_cast(str), str + N, @@ -725,7 +728,7 @@ size_t formatted_size(const CompiledFormat& cf, const Args&... args) { return format_to(detail::counting_iterator(), cf, args...).count(); } -#ifdef FMT_USE_NONTYPE_TEMPLATE_PARAMETERS +#if FMT_USE_NONTYPE_TEMPLATE_PARAMETERS inline namespace literals { template constexpr detail::udl_compiled_string, diff --git a/test/compile-test.cc b/test/compile-test.cc index 1e6292b7..d328077e 100644 --- a/test/compile-test.cc +++ b/test/compile-test.cc @@ -179,7 +179,7 @@ TEST(CompileTest, Empty) { } #endif -#ifdef FMT_USE_NONTYPE_TEMPLATE_PARAMETERS +#if FMT_USE_NONTYPE_TEMPLATE_PARAMETERS TEST(CompileTest, CompileFormatStringLiteral) { using namespace fmt::literals; EXPECT_EQ("", fmt::format(""_cf));