diff --git a/include/fmt/base.h b/include/fmt/base.h index da573887..51a4afa8 100644 --- a/include/fmt/base.h +++ b/include/fmt/base.h @@ -153,14 +153,6 @@ # define FMT_USE_NONTYPE_TEMPLATE_ARGS 0 #endif -#ifdef FMT_USE_CONCEPTS -// Use the provided definition. -#elif defined(__cpp_concepts) -# define FMT_USE_CONCEPTS 1 -#else -# define FMT_USE_CONCEPTS 0 -#endif - // Check if exceptions are disabled. #ifdef FMT_EXCEPTIONS // Use the provided definition. @@ -377,15 +369,6 @@ struct monostate { # define FMT_ENABLE_IF(...) fmt::enable_if_t<(__VA_ARGS__), int> = 0 #endif -// This is defined in base.h instead of format.h to avoid injecting in std. -// It is a template to avoid undesirable implicit conversions to std::byte. -#ifdef __cpp_lib_byte -template ::value)> -inline auto format_as(T b) -> unsigned char { - return static_cast(b); -} -#endif - namespace detail { // Suppresses "unused variable" warnings with the method described in // https://herbsutter.com/2009/10/18/mailbag-shutting-up-compiler-warnings/. @@ -1804,6 +1787,20 @@ FMT_EXPORT template class basic_format_arg; FMT_EXPORT template class basic_format_args; FMT_EXPORT template class dynamic_format_arg_store; +class context; +template class generic_context; + +template class basic_appender; + +template +using buffered_context = + conditional_t::value, context, + generic_context, Char>>; + +// A separate type would result in shorter symbols but break ABI compatibility +// between clang and gcc on ARM (#1919). +using format_args = basic_format_args; + // A formatter for objects of type T. FMT_EXPORT template @@ -1818,6 +1815,15 @@ template using has_formatter = std::is_constructible>; +// This is defined in base.h instead of format.h to avoid injecting in std. +// It is a template to avoid undesirable implicit conversions to std::byte. +#ifdef __cpp_lib_byte +template ::value)> +inline auto format_as(T b) -> unsigned char { + return static_cast(b); +} +#endif + // An output iterator that appends to a buffer. It is used instead of // back_insert_iterator to reduce symbol sizes and avoid dependency. template class basic_appender { @@ -2260,10 +2266,6 @@ struct is_output_iterator< void_t&>()++ = std::declval())>> : std::true_type {}; -#ifndef FMT_OPTIMIZE_SIZE -# define FMT_OPTIMIZE_SIZE 0 -#endif - #ifdef FMT_USE_LOCALE // Use the provided definition. #elif defined(FMT_STATIC_THOUSANDS_SEPARATOR) @@ -2693,17 +2695,6 @@ class context { FMT_CONSTEXPR auto locale() -> detail::locale_ref { return loc_; } }; - -template class generic_context; - -template -using buffered_context = - conditional_t::value, context, - generic_context, Char>>; - -// A separate type would result in shorter symbols but break ABI compatibility -// between clang and gcc on ARM (#1919). -using format_args = basic_format_args; FMT_END_EXPORT namespace detail { @@ -2925,7 +2916,7 @@ using is_formattable = bool_constant< decltype(detail::arg_mapper>::map( std::declval()))>::value>; -#if FMT_USE_CONCEPTS +#ifdef __cpp_concepts template concept formattable = is_formattable, Char>::value; #endif diff --git a/include/fmt/format.h b/include/fmt/format.h index 1c156ba6..6cc42cf5 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -146,6 +146,10 @@ FMT_END_NAMESPACE # endif #endif +#ifndef FMT_OPTIMIZE_SIZE +# define FMT_OPTIMIZE_SIZE 0 +#endif + // Defining FMT_REDUCE_INT_INSTANTIATIONS to 1, will reduce the number of // integer formatter template instantiations to just one by only using the // largest integer type. This results in a reduction in binary size but will diff --git a/test/base-test.cc b/test/base-test.cc index 1a70c23e..357185d4 100644 --- a/test/base-test.cc +++ b/test/base-test.cc @@ -707,8 +707,8 @@ TEST(base_test, is_formattable) { static_assert(!fmt::is_formattable::value, ""); } -#if FMT_USE_CONCEPTS -TEST(base_test, formattable) { +#ifdef __cpp_concepts +TEST(base_test, formattable_concept) { static_assert(fmt::formattable); static_assert(fmt::formattable); static_assert(fmt::formattable);