Skip to content

Commit 31b53e2

Browse files
committed
Move swap additions from 4187 to 3638
1 parent 562fc9f commit 31b53e2

File tree

2 files changed

+233
-4
lines changed

2 files changed

+233
-4
lines changed

xml/issue3638.xml

Lines changed: 190 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,15 +379,204 @@ Rebase on the current draft, change "exchanges the contents" to
379379
new subclauses.
380380
</p>
381381

382+
<superseded>
383+
<p>
384+
This wording is relative to <paper num="N4988"/>.
385+
</p>
386+
387+
<ol>
388+
389+
<li><p>Add to the synopsis in <sref ref="[vector.bool.pspc]"/> p1:</p>
390+
391+
<blockquote>
392+
<pre>
393+
[&hellip;]
394+
<i>// bit reference</i>
395+
class reference {
396+
friend class vector;
397+
constexpr reference() noexcept;
398+
399+
public:
400+
constexpr reference(const reference&amp;) = default;
401+
constexpr ~reference();
402+
constexpr operator bool() const noexcept;
403+
constexpr reference&amp; operator=(bool x) noexcept;
404+
constexpr reference&amp; operator=(const reference&amp; x) noexcept;
405+
constexpr const reference&amp; operator=(bool x) const noexcept;
406+
constexpr void flip() noexcept; <i>// flips the bit</i>
407+
408+
<ins> friend constexpr void swap(reference x, reference y) noexcept;
409+
friend constexpr void swap(reference x, bool&amp; y) noexcept;
410+
friend constexpr void swap(bool&amp; x, reference y) noexcept;</ins>
411+
};
412+
[&hellip;]
413+
</pre>
414+
</blockquote>
415+
</li>
416+
417+
<li><p>Remove the static <tt>swap</tt> function from the same synopsis:</p>
418+
419+
<blockquote>
420+
<pre>
421+
[&hellip;]
422+
constexpr void swap(vector&amp;)
423+
noexcept(allocator_traits&lt;Allocator&gt;::propagate_on_container_swap::value ||
424+
allocator_traits&lt;Allocator&gt;::is_always_equal::value);
425+
<del>static constexpr void swap(reference x, reference y) noexcept;</del>
426+
constexpr void flip() noexcept; <i>// flips all bits</i>
427+
constexpr void clear() noexcept;
428+
[&hellip;]
429+
</pre>
430+
</blockquote>
431+
</li>
432+
433+
<li><p>Modify the paragraphs below the synopsis as shown:</p>
434+
435+
<blockquote>
436+
<p>
437+
-4- <tt>reference</tt> is a class that simulates the behavior of references of a single bit in <tt>vector&lt;bool&gt;</tt>.
438+
The conversion function returns <tt>true</tt> when the bit is set, and <tt>false</tt> otherwise. The assignment
439+
operators set the bit when the argument
440+
<del>is (convertible to)</del>
441+
<ins>converts to</ins>
442+
<tt>true</tt> and clear it otherwise.
443+
<tt>flip</tt> reverses the state of the bit.
444+
</p>
445+
<pre>
446+
<ins>constexpr void reference::flip() noexcept;</ins>
447+
</pre>
448+
<blockquote>
449+
<p>
450+
<ins>-?- <i>Effects:</i> <tt>*this = !*this;</tt></ins>
451+
</p>
452+
</blockquote>
453+
<pre><ins>
454+
constexpr void swap(reference x, reference y) noexcept;
455+
constexpr void swap(reference x, bool&amp; y) noexcept;
456+
constexpr void swap(bool&amp; x, reference y) noexcept;
457+
</ins></pre>
458+
<blockquote>
459+
<p>
460+
<ins>-?- <i>Effects:</i> Exchanges the values denoted by <tt>x</tt> and <tt>y</tt> as if by:</ins>
461+
</p>
462+
<blockquote><pre>
463+
<ins>bool b = x;
464+
x = y;
465+
y = b;</ins>
466+
</pre></blockquote>
467+
</blockquote>
468+
469+
<pre>
470+
constexpr void flip() noexcept;
471+
</pre>
472+
<blockquote>
473+
<p>
474+
-1- <i>Effects:</i> Replaces each element in the container with its complement.
475+
</p>
476+
</blockquote>
477+
<pre>
478+
<del>constexpr static void swap(reference x, reference y) noexcept;</del>
479+
</pre>
480+
<blockquote>
481+
<p>
482+
<del>-6- <i>Effects:</i> Exchanges the contents of <tt>x</tt> and <tt>y</tt> as if by:</del>
483+
</p>
484+
<blockquote><pre>
485+
<del>bool b = x;
486+
x = y;
487+
y = b;</del>
488+
</pre></blockquote>
489+
</blockquote>
490+
<pre>
491+
template&lt;class Allocator&gt; struct hash&lt;vector&lt;bool, Allocator&gt;&gt;;
492+
</pre>
493+
<blockquote>
494+
<p>
495+
-7- The specialization is enabled (<sref ref="[unord.hash]"/>).
496+
</p>
497+
</blockquote>
498+
</blockquote>
499+
</li>
500+
501+
<li><p>Create a new subclause [depr.vector.bool.swap] after <sref ref="[depr.format]"/></p>
502+
503+
<blockquote>
504+
<p>
505+
<ins><b>D.? Deprecated <tt>vector&lt;bool, Allocator&gt;</tt> swap [depr.vector.bool.swap]</b></ins>
506+
<p/>
507+
<ins>-?- The following member is declared in addition to those members specified in <sref ref="[vector.bool]"/>:</ins>
508+
</p>
509+
<pre>
510+
<ins>namespace std {
511+
template&lt;class Allocator&gt; class vector&lt;bool, Allocator&gt; {
512+
public:
513+
static constexpr void swap(reference x, reference y) noexcept;
514+
};
515+
}</ins>
516+
</pre>
517+
<pre>
518+
<ins>static constexpr void swap(reference x, reference y) noexcept;</ins>
519+
</pre>
520+
<blockquote>
521+
<p>
522+
<ins>-?- <i>Effects:</i> Exchanges the values denoted by <tt>x</tt> and <tt>y</tt> as if by:</ins>
523+
</p>
524+
<blockquote><pre>
525+
<ins>bool b = x;
526+
x = y;
527+
y = b;</ins>
528+
</pre></blockquote>
529+
</blockquote>
530+
</blockquote>
531+
</li>
532+
533+
</ol>
534+
535+
</superseded>
536+
537+
<note>2025-02-07; Jonathan provides improved wording</note>
538+
<p>
539+
Add `swap` for `bitset::reference`, as proposed in LWG <iref ref="4187"/>.
540+
</p>
541+
382542
</discussion>
383543

384544
<resolution>
385545
<p>
386-
This wording is relative to <paper num="N4988"/>.
546+
This wording is relative to <paper num="N5001"/>.
387547
</p>
388548

389549
<ol>
390550

551+
<li><p>Modify <sref ref="[template.bitset.general]"/> as indicated:</p>
552+
553+
<blockquote>
554+
<pre>
555+
namespace std {
556+
template&lt;size_t N&gt; class bitset {
557+
public:
558+
// <i>bit reference</i>
559+
class reference {
560+
public:
561+
constexpr reference(const reference&amp;) = default;
562+
constexpr ~reference();
563+
constexpr reference&amp; operator=(bool x) noexcept; // <i>for b[i] = x;</i>
564+
constexpr reference&amp; operator=(const reference&amp;) noexcept; // <i>for b[i] = b[j];</i>
565+
constexpr bool operator~() const noexcept; // <i>flips the bit</i>
566+
constexpr operator bool() const noexcept; // <i>for x = b[i];</i>
567+
constexpr reference&amp; flip() noexcept; // <i>for b[i].flip();</i>
568+
<ins> friend constexpr void swap(reference x, reference y) noexcept;
569+
friend constexpr void swap(reference x, bool&amp; y) noexcept;
570+
friend constexpr void swap(bool&amp; x, reference y) noexcept;</ins>
571+
};
572+
[&hellip;]
573+
};
574+
[&hellip;]
575+
}
576+
</pre>
577+
</blockquote>
578+
</li>
579+
391580
<li><p>Add to the synopsis in <sref ref="[vector.bool.pspc]"/> p1:</p>
392581

393582
<blockquote>

xml/issue4187.xml

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ Set priority to 3 after reflector poll.
5757
"The `swap` part belongs in LWG <iref ref="3638"/>."
5858
</p>
5959

60-
</discussion>
61-
62-
<resolution>
60+
<superseded>
6361
<p>
6462
This wording is relative to <paper num="N5001"/>.
6563
</p>
@@ -98,6 +96,48 @@ namespace std {
9896
</li>
9997

10098
</ol>
99+
</superseded>
100+
101+
<note>2025-02-07; Jonathan provides improved wording</note>
102+
<p>Moved `swap` changes to LWG <iref ref="3638"/>.</p>
103+
104+
</discussion>
105+
106+
<resolution>
107+
<p>
108+
This wording is relative to <paper num="N5001"/>.
109+
</p>
110+
111+
<ol>
112+
<li><p>Modify <sref ref="[template.bitset.general]"/> as indicated:</p>
113+
114+
<blockquote>
115+
<pre>
116+
namespace std {
117+
template&lt;size_t N&gt; class bitset {
118+
public:
119+
// <i>bit reference</i>
120+
class reference {
121+
public:
122+
constexpr reference(const reference&amp;) = default;
123+
constexpr ~reference();
124+
constexpr reference&amp; operator=(bool x) noexcept; // <i>for b[i] = x;</i>
125+
constexpr reference&amp; operator=(const reference&amp;) noexcept; // <i>for b[i] = b[j];</i>
126+
<ins>constexpr const reference&amp; operator=(bool x) const noexcept;</ins>
127+
constexpr bool operator~() const noexcept; // <i>flips the bit</i>
128+
constexpr operator bool() const noexcept; // <i>for x = b[i];</i>
129+
constexpr reference&amp; flip() noexcept; // <i>for b[i].flip();</i>
130+
};
131+
[&hellip;]
132+
};
133+
[&hellip;]
134+
}
135+
</pre>
136+
</blockquote>
137+
138+
</li>
139+
</ol>
140+
101141
</resolution>
102142

103143
</issue>

0 commit comments

Comments
 (0)