Skip to content

Commit 5a37fcd

Browse files
authored
Merge 2022-11 LWG Motion 14
P2696R0 Introduce Cpp17Swappable as additional convenience requirements
2 parents c4eec66 + 63c3c1c commit 5a37fcd

File tree

6 files changed

+32
-33
lines changed

6 files changed

+32
-33
lines changed

source/containers.tex

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -612,13 +612,13 @@
612612
container type other than \tcode{array}, shall exchange the values of \tcode{a} and
613613
\tcode{b} without invoking any move, copy, or swap operations on the individual
614614
container elements.
615-
Lvalues of any \tcode{Compare}, \tcode{Pred}, or \tcode{Hash} types
616-
belonging to \tcode{a} and \tcode{b} shall be swappable
615+
Any \tcode{Compare}, \tcode{Pred}, or \tcode{Hash} types
616+
belonging to \tcode{a} and \tcode{b} shall meet the \oldconcept{Swappable} requirements
617617
and shall be exchanged by calling \tcode{swap}
618618
as described in~\ref{swappable.requirements}. If
619619
\tcode{allocator_traits<allocator_type>::propagate_on_container_swap::value} is
620620
\tcode{true}, then
621-
lvalues of type \tcode{allocator_type} shall be swappable and
621+
\tcode{allocator_type} shall meet the \oldconcept{Swap\-pable} requirements and
622622
the allocators of \tcode{a} and \tcode{b} shall also be exchanged
623623
by calling \tcode{swap} as described in~\ref{swappable.requirements}.
624624
Otherwise, the allocators shall not be swapped, and the behavior is
@@ -1550,9 +1550,10 @@
15501550
For \tcode{vector} and \tcode{deque},
15511551
\tcode{T} is also
15521552
\oldconcept{MoveInsertable} into \tcode{X},
1553+
and \tcode{T} meets the
15531554
\oldconcept{MoveConstructible},
15541555
\oldconcept{MoveAssignable}, and
1555-
lvalues of type \tcode{T} are swappable\iref{swappable.requirements}.
1556+
\oldconcept{Swappable}\iref{swappable.requirements} requirements.
15561557
Neither \tcode{i} nor \tcode{j} are iterators into \tcode{a}.
15571558

15581559
\pnum
@@ -1584,9 +1585,10 @@
15841585
For \tcode{vector} and \tcode{deque},
15851586
\tcode{T} is also
15861587
\oldconcept{MoveInsertable} into \tcode{X},
1588+
and \tcode{T} meets the
15871589
\oldconcept{MoveConstructible},
1588-
\oldconcept{MoveAssignable}, and
1589-
lvalues of type \tcode{T} are swappable\iref{swappable.requirements}.
1590+
\oldconcept{Move\-Assignable}, and
1591+
\oldconcept{Swappable}\iref{swappable.requirements} requirements.
15901592
\tcode{rg} and \tcode{a} do not overlap.
15911593

15921594
\pnum

source/iterators.tex

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2011,9 +2011,8 @@
20112011
\pnum
20122012
A type \tcode{X} meets the \defnoldconcept{Iterator} requirements if:
20132013
\begin{itemize}
2014-
\item \tcode{X} meets the \oldconcept{CopyConstructible}, \oldconcept{CopyAssignable}, and
2015-
\oldconcept{Destructible} requirements\iref{utility.arg.requirements} and lvalues
2016-
of type \tcode{X} are swappable\iref{swappable.requirements}, and
2014+
\item \tcode{X} meets the \oldconcept{CopyConstructible}, \oldconcept{CopyAssignable}, \oldconcept{Swappable}, and
2015+
\oldconcept{Destructible} requirements\iref{utility.arg.requirements,swappable.requirements}, and
20172016

20182017
\item \tcode{iterator_traits<X>::difference_type} is a signed integer type or \keyword{void}, and
20192018

source/lib-intro.tex

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1766,6 +1766,10 @@
17661766
An rvalue or lvalue \tcode{t} is \defn{swappable} if and only if \tcode{t} is
17671767
swappable with any rvalue or lvalue, respectively, of type \tcode{T}.
17681768

1769+
\pnum
1770+
A type \tcode{X} meets the \oldconcept{Swappable} requirements
1771+
if lvalues of type \tcode{X} are swappable.
1772+
17691773
\pnum
17701774
A type \tcode{X} meeting any of the iterator requirements\iref{iterator.requirements}
17711775
meets the \oldconcept{ValueSwappable} requirements if,
@@ -1789,7 +1793,7 @@
17891793
// for rvalues and lvalues
17901794
}
17911795

1792-
// Preconditions: lvalues of \tcode{T} are swappable.
1796+
// Preconditions: \tcode{T} meets the \oldconcept{Swappable} requirements.
17931797
template<class T>
17941798
void lv_swap(T& t1, T& t2) {
17951799
using std::swap;
@@ -1828,9 +1832,7 @@
18281832
\begin{itemize}
18291833
\item \tcode{P} meets the \oldconcept{EqualityComparable},
18301834
\oldconcept{DefaultConstructible}, \oldconcept{CopyConstructible}, \oldconcept{\-Copy\-Assign\-able},
1831-
and \oldconcept{Destructible} requirements,
1832-
1833-
\item lvalues of type \tcode{P} are swappable\iref{swappable.requirements},
1835+
\oldconcept{Swappable}, and \oldconcept{Destructible} requirements,
18341836

18351837
\item the expressions shown in \tref{cpp17.nullablepointer} are
18361838
valid and have the indicated semantics, and
@@ -2636,7 +2638,7 @@
26362638
\tcode{true_type} only if an allocator of type \tcode{X} should be swapped
26372639
when the client container is swapped;
26382640
if so,
2639-
lvalues of type \tcode{X} shall be swappable\iref{swappable.requirements} and
2641+
\tcode{X} shall meet the \oldconcept{Swappable} requirements\iref{swappable.requirements} and
26402642
the \tcode{swap} operation shall not throw exceptions.
26412643

26422644
\pnum

source/support.tex

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3397,11 +3397,10 @@
33973397
The type \tcode{source_location} meets the
33983398
\oldconcept{DefaultConstructible},
33993399
\oldconcept{CopyConstructible},
3400-
\oldconcept{Copy\-Assignable}, and
3400+
\oldconcept{Copy\-Assignable},
3401+
\oldconcept{Swappable}, and
34013402
\oldconcept{Destructible}
3402-
requirements\iref{utility.arg.requirements}.
3403-
Lvalues of type \tcode{source_location}
3404-
are swappable\iref{swappable.requirements}.
3403+
requirements\iref{utility.arg.requirements,swappable.requirements}.
34053404
All of the following conditions are \tcode{true}:
34063405
\begin{itemize}
34073406
\item \tcode{is_nothrow_move_constructible_v<source_location>}

source/time.tex

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,16 +1017,14 @@
10171017
\item the types \tcode{TC::rep}, \tcode{TC::duration}, and \tcode{TC::time_point}
10181018
meet the \oldconcept{EqualityComparable} (\tref{cpp17.equalitycomparable}) and
10191019
\oldconcept{LessThanComparable} (\tref{cpp17.lessthancomparable})
1020+
and \oldconcept{Swappable}\iref{swappable.requirements}
10201021
requirements and the requirements of
10211022
numeric types\iref{numeric.requirements}.
10221023
\begin{note}
10231024
This means, in particular,
10241025
that operations on these types will not throw exceptions.
10251026
\end{note}
10261027

1027-
\item lvalues of the types \tcode{TC::rep}, \tcode{TC::duration}, and
1028-
\tcode{TC::time_point} are swappable\iref{swappable.requirements},
1029-
10301028
\item the function \tcode{TC::now()} does not throw exceptions, and
10311029

10321030
\item the type \tcode{TC::time_point::clock} meets the \oldconcept{TrivialClock}

source/utilities.tex

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2472,6 +2472,9 @@
24722472
\end{itemdecl}
24732473

24742474
\begin{itemdescr}
2475+
\pnum
2476+
Let $i$ be in the range \range{0}{sizeof...(Types)} in order.
2477+
24752478
\pnum
24762479
\mandates
24772480
\begin{itemize}
@@ -2485,13 +2488,11 @@
24852488

24862489
\pnum
24872490
\expects
2488-
Each element in \tcode{*this} is swappable with\iref{swappable.requirements}
2489-
the corresponding element in \tcode{rhs}.
2491+
For all $i$, \tcode{get<$i$>(*this)} is swappable with\iref{swappable.requirements} \tcode{get<$i$>(rhs)}.
24902492

24912493
\pnum
24922494
\effects
2493-
Calls \tcode{swap} for each element in \tcode{*this} and its
2494-
corresponding element in \tcode{rhs}.
2495+
For each $i$, calls \tcode{swap} for \tcode{get<$i$>(*this)} with \tcode{get<$i$>(rhs)}.
24952496

24962497
\pnum
24972498
\throws
@@ -3942,7 +3943,7 @@
39423943

39433944
\pnum
39443945
\expects
3945-
Lvalues of type \tcode{T} are swappable.
3946+
\tcode{T} meets the \oldconcept{Swappable} requirements\iref{swappable.requirements}.
39463947

39473948
\pnum
39483949
\effects
@@ -5713,7 +5714,7 @@
57135714

57145715
\pnum
57155716
\expects
5716-
Lvalues of type $\tcode{T}_i$ are swappable\iref{swappable.requirements}.
5717+
Each $\tcode{T}_i$ meets the \oldconcept{Swappable} requirements\iref{swappable.requirements}.
57175718

57185719
\pnum
57195720
\effects
@@ -13732,7 +13733,7 @@
1373213733
with \tcode{Key} as the function
1373313734
call argument type, the \oldconcept{Default\-Constructible} requirements (\tref{cpp17.defaultconstructible}),
1373413735
the \oldconcept{CopyAssignable} requirements (\tref{cpp17.copyassignable}),
13735-
\item be swappable\iref{swappable.requirements} for lvalues,
13736+
the \oldconcept{Swappable} requirements\iref{swappable.requirements},
1373613737
\item meet the requirement that if \tcode{k1 == k2} is \tcode{true}, \tcode{h(k1) == h(k2)} is
1373713738
also \tcode{true}, where \tcode{h} is an object of type \tcode{hash<Key>} and \tcode{k1} and \tcode{k2}
1373813739
are objects of type \tcode{Key};
@@ -15661,13 +15662,11 @@
1566115662
\begin{itemize}
1566215663
\item \oldconcept{DefaultConstructible} (\tref{cpp17.defaultconstructible}),
1566315664
\item \oldconcept{CopyConstructible} (\tref{cpp17.copyconstructible}),
15664-
\item \oldconcept{CopyAssignable} (\tref{cpp17.copyassignable}), and
15665+
\item \oldconcept{CopyAssignable} (\tref{cpp17.copyassignable}),
15666+
\item \oldconcept{Swappable}\iref{swappable.requirements}, and
1566515667
\item \oldconcept{Destructible} (\tref{cpp17.destructible})
1566615668
\end{itemize}
15667-
requirements,
15668-
15669-
\item
15670-
it is swappable\iref{swappable.requirements} for lvalues, and
15669+
requirements, and
1567115670

1567215671
\item
1567315672
the expressions shown in \tref{formatter.basic} are valid and

0 commit comments

Comments
 (0)