Skip to content

Commit fece3bb

Browse files
author
Dawn Perchik
committed
P0602R4 variant and optional should propagate copy/move triviality
1 parent 12935b8 commit fece3bb

File tree

1 file changed

+36
-15
lines changed

1 file changed

+36
-15
lines changed

source/utilities.tex

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2224,8 +2224,8 @@
22242224

22252225
// \ref{optional.assign}, assignment
22262226
optional& operator=(nullopt_t) noexcept;
2227-
optional& operator=(const optional&);
2228-
optional& operator=(optional&&) noexcept(@\seebelow@);
2227+
constexpr optional& operator=(const optional&);
2228+
constexpr optional& operator=(optional&&) noexcept(@\seebelow@);
22292229
template<class U = T> optional& operator=(U&&);
22302230
template<class U> optional& operator=(const optional<U>&);
22312231
template<class U> optional& operator=(optional<U>&&);
@@ -2325,7 +2325,7 @@
23252325
This constructor shall be defined as deleted unless
23262326
\tcode{is_copy_constructible_v<T>} is \tcode{true}.
23272327
If \tcode{is_trivially_copy_constructible_v<T>} is \tcode{true},
2328-
this constructor shall be a \tcode{constexpr} constructor.
2328+
this constructor is trivial..
23292329
\end{itemdescr}
23302330

23312331
\indexlibrary{\idxcode{optional}!constructor}%
@@ -2355,7 +2355,7 @@
23552355
This constructor shall not participate in overload resolution
23562356
unless \tcode{is_move_constructible_v<T>} is \tcode{true}.
23572357
If \tcode{is_trivially_move_constructible_v<T>} is \tcode{true},
2358-
this constructor shall be a \tcode{constexpr} constructor.
2358+
this constructor is trivial.
23592359
\end{itemdescr}
23602360

23612361
\indexlibrary{\idxcode{optional}!constructor}%
@@ -2565,7 +2565,7 @@
25652565

25662566
\indexlibrarymember{operator=}{optional}%
25672567
\begin{itemdecl}
2568-
optional<T>& operator=(const optional& rhs);
2568+
constexpr optional<T>& operator=(const optional& rhs);
25692569
\end{itemdecl}
25702570

25712571
\begin{itemdescr}
@@ -2603,11 +2603,15 @@
26032603
This operator shall be defined as deleted unless
26042604
\tcode{is_copy_constructible_v<T>} is \tcode{true} and
26052605
\tcode{is_copy_assignable_v<T>} is \tcode{true}.
2606+
If \tcode{is_trivially_copy_constructible_v<T> \&\&}
2607+
\tcode{is_trivially_copy_assignable_v<T> \&\&}
2608+
\tcode{is_trivially_destructible_v<T>} is \tcode{true},
2609+
this assignment operator is trivial.
26062610
\end{itemdescr}
26072611

26082612
\indexlibrarymember{operator=}{optional}%
26092613
\begin{itemdecl}
2610-
optional<T>& operator=(optional&& rhs) noexcept(@\seebelow@);
2614+
constexpr optional<T>& operator=(optional&& rhs) noexcept(@\seebelow@);
26112615
\end{itemdecl}
26122616

26132617
\begin{itemdescr}
@@ -2653,6 +2657,10 @@
26532657
This operator shall not participate in overload resolution unless
26542658
\tcode{is_move_constructible_v<T>} is \tcode{true} and
26552659
\tcode{is_move_assignable_v<T>} is \tcode{true}.
2660+
If \tcode{is_trivially_move_constructible_v<T> \&\&}
2661+
\tcode{is_trivially_move_assignable_v<T> \&\&}
2662+
\tcode{is_trivially_destructible_v<T>} is \tcode{true},
2663+
this assignment operator is trivial.
26562664
\end{itemdescr}
26572665

26582666
\indexlibrarymember{operator=}{optional}%
@@ -3803,8 +3811,8 @@
38033811
public:
38043812
// \ref{variant.ctor}, constructors
38053813
constexpr variant() noexcept(@\seebelow@);
3806-
variant(const variant&);
3807-
variant(variant&&) noexcept(@\seebelow@);
3814+
constexpr variant(const variant&);
3815+
constexpr variant(variant&&) noexcept(@\seebelow@);
38083816

38093817
template<class T>
38103818
constexpr variant(T&&) noexcept(@\seebelow@);
@@ -3823,8 +3831,8 @@
38233831
~variant();
38243832

38253833
// \ref{variant.assign}, assignment
3826-
variant& operator=(const variant&);
3827-
variant& operator=(variant&&) noexcept(@\seebelow@);
3834+
constexpr variant& operator=(const variant&);
3835+
constexpr variant& operator=(variant&&) noexcept(@\seebelow@);
38283836

38293837
template<class T> variant& operator=(T&&) noexcept(@\seebelow@);
38303838

@@ -3908,7 +3916,7 @@
39083916

39093917
\indexlibrary{\idxcode{variant}!constructor}%
39103918
\begin{itemdecl}
3911-
variant(const variant& w);
3919+
constexpr variant(const variant& w);
39123920
\end{itemdecl}
39133921

39143922
\begin{itemdescr}
@@ -3927,11 +3935,13 @@
39273935
\remarks
39283936
This constructor shall be defined as deleted unless
39293937
\tcode{is_copy_constructible_v<$\tcode{T}_i$>} is \tcode{true} for all $i$.
3938+
If \tcode{is_trivially_copy_constructible_v<$\tcode{T}_i$>}
3939+
is \tcode{true} for all $i$, this constructor is trivial.
39303940
\end{itemdescr}
39313941

39323942
\indexlibrary{\idxcode{variant}!constructor}%
39333943
\begin{itemdecl}
3934-
variant(variant&& w) noexcept(@\seebelow@);
3944+
constexpr variant(variant&& w) noexcept(@\seebelow@);
39353945
\end{itemdecl}
39363946

39373947
\begin{itemdescr}
@@ -3952,6 +3962,8 @@
39523962
\tcode{is_nothrow_move_constructible_v<$\tcode{T}_i$>} for all $i$.
39533963
This function shall not participate in overload resolution unless
39543964
\tcode{is_move_constructible_v<$\tcode{T}_i$>} is \tcode{true} for all $i$.
3965+
If \tcode{is_trivially_move_constructible_v<$\tcode{T}_i$>}
3966+
is \tcode{true} for all $i$, this constructor is trivial.
39553967
\end{itemdescr}
39563968

39573969
\indexlibrary{\idxcode{variant}!constructor}%
@@ -4165,7 +4177,7 @@
41654177

41664178
\indexlibrarymember{operator=}{variant}%
41674179
\begin{itemdecl}
4168-
variant& operator=(const variant& rhs);
4180+
constexpr variant& operator=(const variant& rhs);
41694181
\end{itemdecl}
41704182

41714183
\begin{itemdescr}
@@ -4204,11 +4216,15 @@
42044216
\tcode{is_copy_constructible_v<$\tcode{T}_i$> \&\&}
42054217
\tcode{is_copy_assignable_v<$\tcode{T}_i$>}
42064218
is \tcode{true} for all $i$.
4219+
If \tcode{is_trivially_copy_constructible_v<$\tcode{T}_i$> \&\&}
4220+
\tcode{is_trivially_copy_assignable_v<$\tcode{T}_i$> \&\&}
4221+
\tcode{is_trivially_destructible_v<$\tcode{T}_i$>}
4222+
is true for all $i$, this assignment operator is trivial.
42074223
\end{itemdescr}
42084224

42094225
\indexlibrarymember{operator=}{variant}%
42104226
\begin{itemdecl}
4211-
variant& operator=(variant&& rhs) noexcept(@\seebelow@);
4227+
constexpr variant& operator=(variant&& rhs) noexcept(@\seebelow@);
42124228
\end{itemdecl}
42134229

42144230
\begin{itemdescr}
@@ -4236,8 +4252,13 @@
42364252
\pnum
42374253
\remarks
42384254
This function shall not participate in overload resolution unless
4239-
\tcode{is_move_constructible_v<$\tcode{T}_i$> \&\& is_move_assignable_v<$\tcode{T}_i$>} is
4255+
\tcode{is_move_constructible_v<$\tcode{T}_i$> \&\&}
4256+
\tcode{is_move_assignable_v<$\tcode{T}_i$>} is
42404257
\tcode{true} for all $i$.
4258+
If \tcode{is_trivially_move_constructible_v<$\tcode{T}_i$> \&\&}
4259+
\tcode{is_trivially_move_assignable_v<$\tcode{T}_i$> \&\&}
4260+
\tcode{is_trivially_destructible_v<$\tcode{T}_i$>}
4261+
is true for all $i$, this assignment operator is trivial.
42414262
The expression inside \tcode{noexcept} is equivalent to:
42424263
\tcode{is_nothrow_move_constructible_v<$\tcode{T}_i$> \&\& is_nothrow_move_assignable_v<$\tcode{T}_i$>} for all $i$.
42434264
\begin{itemize}

0 commit comments

Comments
 (0)