2121#endif
2222
2323// The fmt library version in the form major * 10000 + minor * 100 + patch.
24- #define FMT_VERSION 110201
24+ #define FMT_VERSION 120000
2525
2626// Detect compiler versions.
2727#if defined(__clang__) && !defined(__ibmxl__)
201201# define FMT_NODISCARD
202202#endif
203203
204- #ifdef FMT_DEPRECATED
205- // Use the provided definition.
206- #elif FMT_HAS_CPP14_ATTRIBUTE(deprecated)
207- # define FMT_DEPRECATED [[deprecated]]
208- #else
209- # define FMT_DEPRECATED /* deprecated */
210- #endif
211-
212204#if FMT_GCC_VERSION || FMT_CLANG_VERSION
213205# define FMT_VISIBILITY (value ) __attribute__((visibility(value)))
214206#else
@@ -260,7 +252,7 @@ FMT_PRAGMA_CLANG(diagnostic push)
260252#ifndef FMT_BEGIN_NAMESPACE
261253# define FMT_BEGIN_NAMESPACE \
262254 namespace fmt { \
263- inline namespace v11 {
255+ inline namespace v12 {
264256# define FMT_END_NAMESPACE \
265257 } \
266258 }
@@ -356,6 +348,9 @@ template <typename T> constexpr auto max_of(T a, T b) -> T {
356348 return a > b ? a : b;
357349}
358350
351+ FMT_NORETURN FMT_API void assert_fail (const char * file, int line,
352+ const char * message);
353+
359354namespace detail {
360355// Suppresses "unused variable" warnings with the method described in
361356// https://herbsutter.com/2009/10/18/mailbag-shutting-up-compiler-warnings/.
@@ -396,7 +391,7 @@ FMT_NORETURN FMT_API void assert_fail(const char* file, int line,
396391# define FMT_ASSERT (condition, message ) \
397392 ((condition) /* void() fails with -Winvalid-constexpr on clang 4.0.1 */ \
398393 ? (void )0 \
399- : fmt::detail ::assert_fail(__FILE__, __LINE__, (message)))
394+ : ::fmt ::assert_fail(__FILE__, __LINE__, (message)))
400395#endif
401396
402397#ifdef FMT_USE_INT128
@@ -463,8 +458,10 @@ enum { use_utf8 = !FMT_WIN32 || is_utf8_enabled };
463458static_assert (!FMT_UNICODE || use_utf8,
464459 " Unicode support requires compiling with /utf-8" );
465460
466- template <typename T> constexpr const char * narrow (const T*) { return nullptr ; }
467- constexpr FMT_ALWAYS_INLINE const char * narrow (const char * s) { return s; }
461+ template <typename T> constexpr auto narrow (T*) -> char* { return nullptr ; }
462+ constexpr FMT_ALWAYS_INLINE auto narrow (const char * s) -> const char* {
463+ return s;
464+ }
468465
469466template <typename Char>
470467FMT_CONSTEXPR auto compare (const Char* s1, const Char* s2, size_t n) -> int {
@@ -615,19 +612,6 @@ template <typename Char> class basic_string_view {
615612
616613using string_view = basic_string_view<char >;
617614
618- // DEPRECATED! Will be merged with is_char and moved to detail.
619- template <typename T> struct is_xchar : std::false_type {};
620- template <> struct is_xchar <wchar_t > : std::true_type {};
621- template <> struct is_xchar <char16_t > : std::true_type {};
622- template <> struct is_xchar <char32_t > : std::true_type {};
623- #ifdef __cpp_char8_t
624- template <> struct is_xchar <char8_t > : std::true_type {};
625- #endif
626-
627- // Specifies if `T` is a character (code unit) type.
628- template <typename T> struct is_char : is_xchar<T> {};
629- template <> struct is_char <char > : std::true_type {};
630-
631615template <typename T> class basic_appender ;
632616using appender = basic_appender<char >;
633617
@@ -780,7 +764,7 @@ class basic_specs {
780764 (static_cast <unsigned >(p) << precision_shift);
781765 }
782766
783- constexpr bool dynamic () const {
767+ constexpr auto dynamic () const -> bool {
784768 return (data_ & (width_mask | precision_mask)) != 0 ;
785769 }
786770
@@ -920,14 +904,47 @@ template <typename Char = char> class parse_context {
920904 FMT_CONSTEXPR void check_dynamic_spec (int arg_id);
921905};
922906
907+ #ifndef FMT_USE_LOCALE
908+ # define FMT_USE_LOCALE (FMT_OPTIMIZE_SIZE <= 1 )
909+ #endif
910+
911+ // A type-erased reference to std::locale to avoid the heavy <locale> include.
912+ class locale_ref {
913+ #if FMT_USE_LOCALE
914+ private:
915+ const void * locale_; // A type-erased pointer to std::locale.
916+
917+ public:
918+ constexpr locale_ref () : locale_(nullptr ) {}
919+
920+ template <typename Locale, FMT_ENABLE_IF(sizeof (Locale::collate) != 0 )>
921+ locale_ref (const Locale& loc);
922+
923+ inline explicit operator bool () const noexcept { return locale_ != nullptr ; }
924+ #endif // FMT_USE_LOCALE
925+
926+ public:
927+ template <typename Locale> auto get () const -> Locale;
928+ };
929+
923930FMT_END_EXPORT
924931
925932namespace detail {
926933
934+ // Specifies if `T` is a code unit type.
935+ template <typename T> struct is_code_unit : std::false_type {};
936+ template <> struct is_code_unit <char > : std::true_type {};
937+ template <> struct is_code_unit <wchar_t > : std::true_type {};
938+ template <> struct is_code_unit <char16_t > : std::true_type {};
939+ template <> struct is_code_unit <char32_t > : std::true_type {};
940+ #ifdef __cpp_char8_t
941+ template <> struct is_code_unit <char8_t > : bool_constant<is_utf8_enabled> {};
942+ #endif
943+
927944// Constructs fmt::basic_string_view<Char> from types implicitly convertible
928945// to it, deducing Char. Explicitly convertible types such as the ones returned
929946// from FMT_STRING are intentionally excluded.
930- template <typename Char, FMT_ENABLE_IF(is_char <Char>::value)>
947+ template <typename Char, FMT_ENABLE_IF(is_code_unit <Char>::value)>
931948constexpr auto to_string_view (const Char* s) -> basic_string_view<Char> {
932949 return s;
933950}
@@ -1056,11 +1073,11 @@ template <bool B1, bool B2, bool... Tail> constexpr auto count() -> int {
10561073 return (B1 ? 1 : 0 ) + count<B2, Tail...>();
10571074}
10581075
1059- template <typename ... Args > constexpr auto count_named_args () -> int {
1060- return count<is_named_arg<Args >::value...>();
1076+ template <typename ... T > constexpr auto count_named_args () -> int {
1077+ return count<is_named_arg<T >::value...>();
10611078}
1062- template <typename ... Args > constexpr auto count_static_named_args () -> int {
1063- return count<is_static_named_arg<Args >::value...>();
1079+ template <typename ... T > constexpr auto count_static_named_args () -> int {
1080+ return count<is_static_named_arg<T >::value...>();
10641081}
10651082
10661083template <typename Char> struct named_arg_info {
@@ -1172,7 +1189,7 @@ template <typename Char> struct type_mapper {
11721189 static auto map (ubitint<N>)
11731190 -> conditional_t<N <= 64, unsigned long long, void>;
11741191
1175- template <typename T, FMT_ENABLE_IF(is_char <T>::value)>
1192+ template <typename T, FMT_ENABLE_IF(is_code_unit <T>::value)>
11761193 static auto map (T) -> conditional_t<
11771194 std::is_same<T, char>::value || std::is_same<T, Char>::value, Char, void>;
11781195
@@ -2192,7 +2209,7 @@ template <typename Context> class value {
21922209 static_assert (N <= 64 , " unsupported _BitInt" );
21932210 }
21942211
2195- template <typename T, FMT_ENABLE_IF(is_char <T>::value)>
2212+ template <typename T, FMT_ENABLE_IF(is_code_unit <T>::value)>
21962213 constexpr FMT_INLINE value (T x FMT_BUILTIN) : char_value(x) {
21972214 static_assert (
21982215 std::is_same<T, char >::value || std::is_same<T, char_type>::value,
@@ -2268,7 +2285,7 @@ template <typename Context> class value {
22682285 custom.value = const_cast <value_type*>(&x);
22692286#endif
22702287 }
2271- custom.format = format_custom<value_type, formatter<value_type, char_type> >;
2288+ custom.format = format_custom<value_type>;
22722289 }
22732290
22742291 template <typename T, FMT_ENABLE_IF(!has_formatter<T, char_type>())>
@@ -2279,11 +2296,10 @@ template <typename Context> class value {
22792296 }
22802297
22812298 // Formats an argument of a custom type, such as a user-defined class.
2282- // DEPRECATED! Formatter template parameter will be removed.
2283- template <typename T, typename Formatter>
2299+ template <typename T>
22842300 static void format_custom (void * arg, parse_context<char_type>& parse_ctx,
22852301 Context& ctx) {
2286- auto f = Formatter ();
2302+ auto f = formatter<T, char_type> ();
22872303 parse_ctx.advance_to (f.parse (parse_ctx));
22882304 using qualified_type =
22892305 conditional_t <has_formatter<const T, char_type>(), const T, T>;
@@ -2310,35 +2326,14 @@ struct is_output_iterator<
23102326 enable_if_t <std::is_assignable<decltype (*std::declval<decay_t <It>&>()++),
23112327 T>::value>> : std::true_type {};
23122328
2313- #ifndef FMT_USE_LOCALE
2314- # define FMT_USE_LOCALE (FMT_OPTIMIZE_SIZE <= 1 )
2315- #endif
2316-
2317- // A type-erased reference to an std::locale to avoid a heavy <locale> include.
2318- class locale_ref {
2319- #if FMT_USE_LOCALE
2320- private:
2321- const void * locale_; // A type-erased pointer to std::locale.
2322-
2323- public:
2324- constexpr locale_ref () : locale_(nullptr ) {}
2325- template <typename Locale> locale_ref (const Locale& loc);
2326-
2327- inline explicit operator bool () const noexcept { return locale_ != nullptr ; }
2328- #endif // FMT_USE_LOCALE
2329-
2330- public:
2331- template <typename Locale> auto get () const -> Locale;
2332- };
2333-
23342329template <typename > constexpr auto encode_types () -> unsigned long long {
23352330 return 0 ;
23362331}
23372332
2338- template <typename Context, typename Arg , typename ... Args >
2333+ template <typename Context, typename First , typename ... T >
23392334constexpr auto encode_types () -> unsigned long long {
2340- return static_cast <unsigned >(stored_type_constant<Arg , Context>::value) |
2341- (encode_types<Context, Args ...>() << packed_arg_bits);
2335+ return static_cast <unsigned >(stored_type_constant<First , Context>::value) |
2336+ (encode_types<Context, T ...>() << packed_arg_bits);
23422337}
23432338
23442339template <typename Context, typename ... T, size_t NUM_ARGS = sizeof ...(T)>
@@ -2376,8 +2371,8 @@ struct named_arg_store {
23762371 }
23772372
23782373 named_arg_store (const named_arg_store& rhs) = delete ;
2379- named_arg_store& operator =(const named_arg_store& rhs) = delete ;
2380- named_arg_store& operator =(named_arg_store&& rhs) = delete ;
2374+ auto operator =(const named_arg_store& rhs) -> named_arg_store& = delete ;
2375+ auto operator =(named_arg_store&& rhs) -> named_arg_store& = delete ;
23812376 operator const arg_t <Context, NUM_ARGS>*() const { return args + 1 ; }
23822377};
23832378
@@ -2674,22 +2669,17 @@ class context {
26742669 private:
26752670 appender out_;
26762671 format_args args_;
2677- FMT_NO_UNIQUE_ADDRESS detail:: locale_ref loc_;
2672+ FMT_NO_UNIQUE_ADDRESS locale_ref loc_;
26782673
26792674 public:
2680- // / The character type for the output.
2681- using char_type = char ;
2682-
2675+ using char_type = char ; // /< The character type for the output.
26832676 using iterator = appender;
26842677 using format_arg = basic_format_arg<context>;
2685- using parse_context_type FMT_DEPRECATED = parse_context<>;
2686- template <typename T> using formatter_type FMT_DEPRECATED = formatter<T>;
26872678 enum { builtin_types = FMT_BUILTIN_TYPES };
26882679
26892680 // / Constructs a `context` object. References to the arguments are stored
26902681 // / in the object so make sure they have appropriate lifetimes.
2691- FMT_CONSTEXPR context (iterator out, format_args args,
2692- detail::locale_ref loc = {})
2682+ FMT_CONSTEXPR context (iterator out, format_args args, locale_ref loc = {})
26932683 : out_(out), args_(args), loc_(loc) {}
26942684 context (context&&) = default ;
26952685 context (const context&) = delete ;
@@ -2710,7 +2700,7 @@ class context {
27102700 // Advances the begin iterator to `it`.
27112701 FMT_CONSTEXPR void advance_to (iterator) {}
27122702
2713- FMT_CONSTEXPR auto locale () const -> detail:: locale_ref { return loc_; }
2703+ FMT_CONSTEXPR auto locale () const -> locale_ref { return loc_; }
27142704};
27152705
27162706template <typename Char = char > struct runtime_format_string {
@@ -2797,9 +2787,6 @@ template <typename T, typename Char = char>
27972787concept formattable = is_formattable<remove_reference_t <T>, Char>::value;
27982788#endif
27992789
2800- template <typename T, typename Char>
2801- using has_formatter FMT_DEPRECATED = std::is_constructible<formatter<T, Char>>;
2802-
28032790// A formatter specialization for natively supported types.
28042791template <typename T, typename Char>
28052792struct formatter <T, Char,
@@ -2996,9 +2983,9 @@ FMT_INLINE void println(format_string<T...> fmt, T&&... args) {
29962983 return fmt::println (stdout, fmt, static_cast <T&&>(args)...);
29972984}
29982985
2999- FMT_END_EXPORT
30002986FMT_PRAGMA_CLANG (diagnostic pop)
30012987FMT_PRAGMA_GCC(pop_options)
2988+ FMT_END_EXPORT
30022989FMT_END_NAMESPACE
30032990
30042991#ifdef FMT_HEADER_ONLY
0 commit comments