Skip to content

Commit b7b31c7

Browse files
committed
New issue from Tomasz: "enable_nonlocking_formatter_optimization should be disabled for container adaptors"
1 parent e722b0f commit b7b31c7

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed

xml/issue4398.xml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?xml version='1.0' encoding='utf-8' standalone='no'?>
2+
<!DOCTYPE issue SYSTEM "lwg-issue.dtd">
3+
4+
<issue num="4398" status="New">
5+
<title>`enable_nonlocking_formatter_optimization` should be disabled for container adaptors</title>
6+
<section><sref ref="[queue.syn]"/><sref ref="[stack.syn]"/></section>
7+
<submitter>Tomasz Kamiński</submitter>
8+
<date>02 Oct 2025</date>
9+
<priority>99</priority>
10+
11+
<discussion>
12+
<p>
13+
As the standard currently defines formatters for `queue`, `prioriy_queue`, and `stack`
14+
`enable_nonlocking_formatter_optimization` is specialized to `true` for these adaptors per
15+
<sref ref="[format.formatter.spec]"/> p3:
16+
</p>
17+
<blockquote>
18+
<p>
19+
Unless specified otherwise, for each type `T` for which a formatter specialization is provided
20+
by the library, each of the headers provides the following specialization:
21+
</p>
22+
<blockquote><pre>
23+
template&lt;&gt; inline constexpr bool enable_nonlocking_formatter_optimization&lt;T&gt; = true;
24+
</pre></blockquote>
25+
</blockquote>
26+
<p>
27+
However, formatting an adaptor requires formatting of the underlying range, and we disable
28+
the nonlocking_optimizations for all ranges.
29+
<p/>
30+
This problem does not occur for the `flat_set`, `flat_map` adaptors, which are also ranges, and
31+
do not have a specialized formatter, and use range one.
32+
</p>
33+
</discussion>
34+
35+
<resolution>
36+
<p>
37+
This wording is relative to <paper num="N5014"/>.
38+
</p>
39+
40+
<ol>
41+
42+
<li><p>Modify <sref ref="[queue.syn]"/>, header <tt>&lt;queue&gt;</tt> synopsis, as indicated:</p>
43+
44+
<blockquote>
45+
<pre>
46+
[&hellip;]
47+
// <i><sref ref="[container.adaptors.format]"/>, formatter specialization for queue</i>
48+
template&lt;class charT, class T, formattable&lt;charT&gt; Container&gt;
49+
struct formatter&lt;queue&lt;T, Container&gt;, charT&gt;;
50+
51+
<ins>template&lt;class T, class Container&gt;
52+
constexpr bool enable_nonlocking_formatter_optimization&lt;queue&lt;T, Container&gt;&gt; = false;</ins>
53+
54+
// <i><sref ref="[priority.queue]"/>, class template priority_queue</i>
55+
template&lt;class T, class Container = vector&lt;T&gt;,
56+
class Compare = less&lt;typename Container::value_type&gt;&gt;
57+
class priority_queue;
58+
[&hellip;]
59+
// <i><sref ref="[container.adaptors.format]"/>, formatter specialization for priority_queue</i>
60+
template&lt;class charT, class T, formattable&lt;charT&gt; Container, class Compare&gt;
61+
struct formatter&lt;priority_queue&lt;T, Container, Compare&gt;, charT&gt;;
62+
63+
<ins>template&lt;class T, class Container, class Compare&gt;
64+
constexpr bool enable_nonlocking_formatter_optimization&lt;priority_queue&lt;T, Container, Compare&gt;&gt; = false;</ins>
65+
[&hellip;]
66+
</pre>
67+
</blockquote>
68+
</li>
69+
70+
<li><p>Modify <sref ref="[stack.syn]"/>, header <tt>&lt;stack&gt;</tt> synopsis, as indicated:</p>
71+
72+
<blockquote>
73+
<pre>
74+
[&hellip;]
75+
76+
// <i><sref ref="[container.adaptors.format]"/>, formatter specialization for stack</i>
77+
template&lt;class charT, class T, formattable&lt;charT&gt; Container&gt;
78+
struct formatter&lt;stack&lt;T, Container&gt;, charT&gt;;
79+
80+
<ins>template&lt;class T, class Container&gt;
81+
constexpr bool enable_nonlocking_formatter_optimization&lt;stack&lt;T, Container&gt;&gt; = false;</ins>
82+
83+
[&hellip;]
84+
</pre>
85+
</blockquote>
86+
</li>
87+
</ol>
88+
89+
</resolution>
90+
91+
</issue>

0 commit comments

Comments
 (0)