table of contents
- Tumbleweed 2026.11.13-1.1
- Leap-16.0
| std::enable_nonlocking_formatter_optimization(3) | C++ Standard Libary | std::enable_nonlocking_formatter_optimization(3) |
NAME¶
std::enable_nonlocking_formatter_optimization - std::enable_nonlocking_formatter_optimization
Synopsis¶
Defined in header <format> template< class T > (since C++23) constexpr bool enable_nonlocking_formatter_optimization = false;
This template can be used by implementations to enable efficient implementations of std::print and std::println.
If std::enable_nonlocking_formatter_optimization<T> is true, printing an argument of type T can be performed in a more efficient way (see std::print for details). std::enable_nonlocking_formatter_optimization specializations can be true in the following cases:
* T is one of the types where std::formatter<T, CharT> is a basic
standard
specialization or standard specialization for a library type (see below).
* A program may specialize this template for any cv-unqualified
program-defined type T.
Such specializations must be usable in constant expressions and have type
const bool.
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<> (1) constexpr bool enable_nonlocking_formatter_optimization<CharT> = true; Nonlocking flag for string formatters template<> (2) constexpr bool enable_nonlocking_formatter_optimization<CharT*> = true; template<> (3) constexpr bool enable_nonlocking_formatter_optimization<const CharT*> = true; template< std::size_t N > (4) constexpr bool enable_nonlocking_formatter_optimization<CharT[N]> = true; template< class Traits, class Alloc >
constexpr bool enable_nonlocking_formatter_optimization (5)
<std::basic_string<CharT, Traits, Alloc>> = true; template< class Traits >
constexpr bool enable_nonlocking_formatter_optimization (6)
<std::basic_string_view<CharT, Traits>> = true; Nonlocking flag for arithmetic formatters template<> (7) constexpr bool enable_nonlocking_formatter_optimization<ArithmeticT> = true; Nonlocking flag for pointer formatters template<> (8) constexpr bool enable_nonlocking_formatter_optimization<std::nullptr_t> = true; template<> (9) constexpr bool enable_nonlocking_formatter_optimization<void*> = true; template<> (10) constexpr bool enable_nonlocking_formatter_optimization<const void*> = true;
Standard specializations for library types¶
Specializations of enable_nonlocking_formatter_optimization for all specializations of the following standard templates are defined as true:
* std::chrono::zoned_time when its template parameter type TimeZonePtr is
const
std::chrono::time_zone*
Specializations of enable_nonlocking_formatter_optimization for all specializations of the following standard templates are defined as conditionally true:
* std::pair
* std::tuple
* std::chrono::duration
Specialization of enable_nonlocking_formatter_optimization for all formattable range types are always defined as false for which the range format kind is not std::range_format::disabled.
Notes¶
Feature-test macro Value Std Feature
202403L (C++26) Formatted output with stream locking __cpp_lib_print (DR23)
202406L (C++26) Enabling nonlocking formatter optimization for more
(DR23) formattable types
See also¶
formatter defines formatting rules for a given type (C++20)
(class template) print prints to stdout or a file stream using
formatted representation of the (C++23) arguments
(function template) println same as std::print except that each print
is terminated by additional new line (C++23) (function template)
| 2026.11.10 | http://cppreference.com |