|
| 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<> inline constexpr bool enable_nonlocking_formatter_optimization<T> = 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><queue></tt> synopsis, as indicated:</p> |
| 43 | + |
| 44 | +<blockquote> |
| 45 | +<pre> |
| 46 | +[…] |
| 47 | +// <i><sref ref="[container.adaptors.format]"/>, formatter specialization for queue</i> |
| 48 | +template<class charT, class T, formattable<charT> Container> |
| 49 | + struct formatter<queue<T, Container>, charT>; |
| 50 | + |
| 51 | +<ins>template<class T, class Container> |
| 52 | + constexpr bool enable_nonlocking_formatter_optimization<queue<T, Container>> = false;</ins> |
| 53 | + |
| 54 | +// <i><sref ref="[priority.queue]"/>, class template priority_queue</i> |
| 55 | +template<class T, class Container = vector<T>, |
| 56 | + class Compare = less<typename Container::value_type>> |
| 57 | + class priority_queue; |
| 58 | +[…] |
| 59 | +// <i><sref ref="[container.adaptors.format]"/>, formatter specialization for priority_queue</i> |
| 60 | +template<class charT, class T, formattable<charT> Container, class Compare> |
| 61 | + struct formatter<priority_queue<T, Container, Compare>, charT>; |
| 62 | + |
| 63 | +<ins>template<class T, class Container, class Compare> |
| 64 | + constexpr bool enable_nonlocking_formatter_optimization<priority_queue<T, Container, Compare>> = false;</ins> |
| 65 | +[…] |
| 66 | +</pre> |
| 67 | +</blockquote> |
| 68 | +</li> |
| 69 | + |
| 70 | +<li><p>Modify <sref ref="[stack.syn]"/>, header <tt><stack></tt> synopsis, as indicated:</p> |
| 71 | + |
| 72 | +<blockquote> |
| 73 | +<pre> |
| 74 | +[…] |
| 75 | + |
| 76 | +// <i><sref ref="[container.adaptors.format]"/>, formatter specialization for stack</i> |
| 77 | +template<class charT, class T, formattable<charT> Container> |
| 78 | + struct formatter<stack<T, Container>, charT>; |
| 79 | + |
| 80 | +<ins>template<class T, class Container> |
| 81 | + constexpr bool enable_nonlocking_formatter_optimization<stack<T, Container>> = false;</ins> |
| 82 | + |
| 83 | +[…] |
| 84 | +</pre> |
| 85 | +</blockquote> |
| 86 | +</li> |
| 87 | +</ol> |
| 88 | + |
| 89 | +</resolution> |
| 90 | + |
| 91 | +</issue> |
0 commit comments