|
| 1 | +<?xml version='1.0' encoding='utf-8' standalone='no'?> |
| 2 | +<!DOCTYPE issue SYSTEM "lwg-issue.dtd"> |
| 3 | + |
| 4 | +<issue num="4399" status="New"> |
| 5 | +<title>`enable_nonlocking_formatter_optimization` for `pair` and `tuple` needs `remove_cvref_t`</title> |
| 6 | +<section><sref ref="[format.tuple]"/></section> |
| 7 | +<submitter>Tomasz Kamiński</submitter> |
| 8 | +<date>02 Oct 2025</date> |
| 9 | +<priority>99</priority> |
| 10 | + |
| 11 | +<discussion> |
| 12 | +<p> |
| 13 | +The `enable_nonlocking_formatter_optimization` variable template is specialized only for <i>cv</i>-unqualified |
| 14 | +types. However, the specialization for `pair` and `tuple` does not remove the references and |
| 15 | +<i>cv</i>-qualifiers from the elements: |
| 16 | +</p> |
| 17 | +<blockquote><pre> |
| 18 | +template<class... Ts> |
| 19 | + constexpr bool enable_nonlocking_formatter_optimization<<i>pair-or-tuple</i><Ts...>> = |
| 20 | + (enable_nonlocking_formatter_optimization<Ts> && ...); |
| 21 | +</pre></blockquote> |
| 22 | +<p> |
| 23 | +As consequence <tt>pair<const std::string, int></tt> or |
| 24 | +<tt>pair<const std::string&, int&></tt> (`map` and `flat_map` reference types) |
| 25 | +will not use unbuffered prints. |
| 26 | +</p> |
| 27 | +</discussion> |
| 28 | + |
| 29 | +<resolution> |
| 30 | +<p> |
| 31 | +This wording is relative to <paper num="N5014"/>. |
| 32 | +</p> |
| 33 | + |
| 34 | +<ol> |
| 35 | + |
| 36 | +<li><p>Modify <sref ref="[format.tuple]"/> as indicated:</p> |
| 37 | + |
| 38 | +<blockquote> |
| 39 | +<p> |
| 40 | +-1- For each of `pair` and `tuple`, the library provides the following formatter specialization |
| 41 | +where <tt><i>pair-or-tuple</i></tt> is the name of the template: |
| 42 | +</p> |
| 43 | +<blockquote> |
| 44 | +<pre> |
| 45 | +namespace std { |
| 46 | + […] |
| 47 | + |
| 48 | + template<class... Ts> |
| 49 | + constexpr bool enable_nonlocking_formatter_optimization<<i>pair-or-tuple</i><Ts...>> = |
| 50 | + (enable_nonlocking_formatter_optimization<<ins>remove_cvref_t<</ins>Ts<ins>></ins>> && ...); |
| 51 | +} |
| 52 | +</pre> |
| 53 | +</blockquote> |
| 54 | +</blockquote> |
| 55 | +</li> |
| 56 | +</ol> |
| 57 | + |
| 58 | +</resolution> |
| 59 | + |
| 60 | +</issue> |
0 commit comments