From cppreference.com
template<classT>constexprboolenable_nonlocking_formatter_optimization=false;(since C++23)This template can be used by implementations to enable efficient implementations of
and
.
If std::enable_nonlocking_formatter_optimization<T> is true, printing an argument of type T can be performed in a more efficient way (see
for details). std::enable_nonlocking_formatter_optimization specializations can be true in the following cases:
T is one of the types where
<T,CharT> is a
or
standard specialization for a library type
(see below).
A program may specialize this template for any cv-unqualified
T. Such specializations must be
usable in constant expressions
and have type constbool.
Basic standard specializations
In the following list, CharT is either char or wchar_t, ArithmeticT is any cv-unqualified arithmetic type other than char, wchar_t, char8_t, char16_t, or char32_t:
Nonlocking flag for character formatters
template<>constexprboolenable_nonlocking_formatter_optimization<CharT>=true; (1) Nonlocking flag for string formatters
template<>constexprboolenable_nonlocking_formatter_optimization<CharT*>=true; (2) template<>constexprboolenable_nonlocking_formatter_optimization<constCharT*>=true; (3) template<std::size_tN>constexprboolenable_nonlocking_formatter_optimization<CharT[N]>=true; (4) template<classTraits,classAlloc>constexprboolenable_nonlocking_formatter_optimization<std::basic_string<CharT,Traits,Alloc>>=true; (5) template<classTraits>constexprboolenable_nonlocking_formatter_optimization<std::basic_string_view<CharT,Traits>>=true; (6) Nonlocking flag for arithmetic formatters
template<>constexprboolenable_nonlocking_formatter_optimization<ArithmeticT>=true; (7) Nonlocking flag for pointer formatters
template<>constexprboolenable_nonlocking_formatter_optimization<std::nullptr_t>=true; (8) template<>constexprboolenable_nonlocking_formatter_optimization<void*>=true; (9) template<>constexprboolenable_nonlocking_formatter_optimization<constvoid*>=true; (10) Standard specializations for library types
Specializations of enable_nonlocking_formatter_optimization for all specializations of the following standard templates are defined as true:
when its template parameter type TimeZonePtr is conststd::chrono::time_zone*
Specializations of enable_nonlocking_formatter_optimization for all specializations of the following standard templates are defined as conditionally true:
Specialization of enable_nonlocking_formatter_optimization for all
are always defined as false for which the range format kind is not std::range_format::disabled.
Notes
macro ValueStdFeature
(C++26)
(DR23)Formatted output with stream locking
(C++26)
(DR23)Enabling nonlocking formatter optimization for more formattable types See also
(C++20)
defines formatting rules for a given type
(class template)
(C++23)
prints to
or a file stream using
representation of the arguments
(function template)
(C++23)
same as std::print except that each print is terminated by additional new line
(function template)