Issue 4399: enable_nonlocking_formatter_optimization for pair and tuple needs remove_cvref_t (original) (raw)
This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of WP status.
4399. enable_nonlocking_formatter_optimization for pair and tuple needs remove_cvref_t
Section: 28.5.9 [format.tuple] Status: WP Submitter: Tomasz Kamiński Opened: 2025-10-02 Last modified: 2025-11-11
Priority: Not Prioritized
View all issues with WP status.
Discussion:
The enable_nonlocking_formatter_optimization variable template is specialized only for _cv_-unqualified types. However, the specialization for pair and tuple does not remove the references and _cv_-qualifiers from the elements:
template<class... Ts> constexpr bool enable_nonlocking_formatter_optimization<_pair-or-tuple_<Ts...>> = (enable_nonlocking_formatter_optimization && ...);
As consequence pair<const std::string, int> or pair<const std::string&, int&> (map and flat_map reference types) will not use unbuffered prints.
The proposed wording has recently been implemented in gcc's libstdc++.
[2025-10-17; Reflector poll]
Set status to Tentatively Ready after seven votes in favour during reflector poll.
[Kona 2025-11-08; Status changed: Voting → WP.]
Proposed resolution:
This wording is relative to N5014.
- Modify 28.5.9 [format.tuple] as indicated:
-1- For each of
pairandtuple, the library provides the following formatter specialization where_pair-or-tuple_is the name of the template:namespace std {
[…]template<class... Ts>
constexpr bool enable_nonlocking_formatter_optimization<_pair-or-tuple_<Ts...>> =
(enable_nonlocking_formatter_optimization<remove_cvref_t> && ...);
}