Skip to content

Commit c307974

Browse files
committed
P0318R1 unwrap_ref_decay and unwrap_reference
Add the type trait as subclause [refwrap.unwrapref], instead of as a sibling of [refwrap]. Rephrase the wording to avoid referencing X before it is introduced. Do not refer to 'equals' as referring to types.
1 parent 12935b8 commit c307974

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

source/utilities.tex

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -854,12 +854,10 @@
854854
\end{itemdecl}
855855

856856
\begin{itemdescr}
857+
Let \tcode{Vi} be \tcode{unwrap_ref_decay_t<Ti>}.
858+
857859
\pnum
858-
\returns \tcode{pair<V1, V2>(std::forward<T1>(x), std::forward<T2>(y))},
859-
where \tcode{V1} and \tcode{V2} are determined as follows: Let \tcode{Ui} be
860-
\tcode{decay_t<Ti>} for each \tcode{Ti}. If \tcode{Ui} is a specialization
861-
of \tcode{reference_wrapper}, then \tcode{Vi} is \tcode{Ui::type\&},
862-
otherwise \tcode{Vi} is \tcode{Ui}.
860+
\returns \tcode{pair<V1, V2>(std::forward<T1>(x), std::forward<T2>(y))}.
863861
\end{itemdescr}
864862

865863
\pnum
@@ -1601,10 +1599,7 @@
16011599

16021600
\begin{itemdescr}
16031601
\pnum
1604-
The pack \tcode{VTypes} is defined as follows. Let \tcode{U}$_i$ be \tcode{decay_t<T$_i$>} for each
1605-
\tcode{T}$_i$ in \tcode{TTypes}. If \tcode{U}$_i$ is a specialization of
1606-
\tcode{reference_wrapper}, then \tcode{V}$_i$ in \tcode{VTypes} is \tcode{U$_i$::type\&},
1607-
otherwise \tcode{V}$_i$ is \tcode{U}$_i$.
1602+
Let \tcode{VTypes...} be \tcode{unwrap_ref_decay_t<TTypes>...}.
16081603

16091604
\pnum
16101605
\returns \tcode{tuple<VTypes...>(std::forward<TTypes>(t)...)}.
@@ -12944,6 +12939,8 @@
1294412939
\rSec2[functional.syn]{Header \tcode{<functional>} synopsis}
1294512940

1294612941
\indexhdr{functional}%
12942+
\indexlibrary{unwrap_ref_decay}%
12943+
\indexlibrary{unwrap_ref_decay_t}%
1294712944
\begin{codeblock}
1294812945
namespace std {
1294912946
// \ref{func.invoke}, invoke
@@ -12962,6 +12959,10 @@
1296212959
template<class T> reference_wrapper<T> ref(reference_wrapper<T>) noexcept;
1296312960
template<class T> reference_wrapper<const T> cref(reference_wrapper<T>) noexcept;
1296412961

12962+
template<class T> struct unwrap_reference;
12963+
template<class T> struct unwrap_ref_decay : unwrap_reference<decay_t<T>> {};
12964+
template<class T> using unwrap_ref_decay_t = typename unwrap_ref_decay<T>::type;
12965+
1296512966
// \ref{arithmetic.operations}, arithmetic operations
1296612967
template<class T = void> struct plus;
1296712968
template<class T = void> struct minus;
@@ -13318,7 +13319,6 @@
1331813319
\pnum\returns The stored reference.
1331913320
\end{itemdescr}
1332013321

13321-
1332213322
\rSec3[refwrap.invoke]{Invocation}
1332313323

1332413324
\indexlibrarymember{operator()}{reference_wrapper}%
@@ -13371,6 +13371,20 @@
1337113371
\pnum\returns \tcode{cref(t.get())}.
1337213372
\end{itemdescr}
1337313373

13374+
\rSec3[refwrap.unwrapref]{Transformation type trait \tcode{unwrap_reference}}
13375+
13376+
\indexlibrary{unwrap_reference}%
13377+
\begin{itemdecl}
13378+
template<class T>
13379+
struct unwrap_reference;
13380+
\end{itemdecl}
13381+
13382+
\pnum
13383+
If \tcode{T} is
13384+
a specialization \tcode{reference_wrapper<X>} for some type \tcode{X},
13385+
the member typedef \tcode{type} of \tcode{unwrap_reference<T>} is \tcode{X\&},
13386+
otherwise it is \tcode{T}.
13387+
1337413388
\rSec2[arithmetic.operations]{Arithmetic operations}
1337513389

1337613390
\pnum

0 commit comments

Comments
 (0)