From 302ce98dd7fd923235d39becd326f7869027755f Mon Sep 17 00:00:00 2001 From: Jens Maurer Date: Thu, 15 Nov 2018 12:15:04 +0100 Subject: [PATCH 1/2] 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. --- source/utilities.tex | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/source/utilities.tex b/source/utilities.tex index c64bb736ce..15333cc800 100644 --- a/source/utilities.tex +++ b/source/utilities.tex @@ -856,12 +856,10 @@ \end{itemdecl} \begin{itemdescr} +Let \tcode{Vi} be \tcode{unwrap_ref_decay_t}. + \pnum -\returns \tcode{pair(std::forward(x), std::forward(y))}, -where \tcode{V1} and \tcode{V2} are determined as follows: Let \tcode{Ui} be -\tcode{decay_t} for each \tcode{Ti}. If \tcode{Ui} is a specialization -of \tcode{reference_wrapper}, then \tcode{Vi} is \tcode{Ui::type\&}, -otherwise \tcode{Vi} is \tcode{Ui}. +\returns \tcode{pair(std::forward(x), std::forward(y))}. \end{itemdescr} \pnum @@ -1615,10 +1613,7 @@ \begin{itemdescr} \pnum -The pack \tcode{VTypes} is defined as follows. Let \tcode{U}$_i$ be \tcode{decay_t} for each -\tcode{T}$_i$ in \tcode{TTypes}. If \tcode{U}$_i$ is a specialization of -\tcode{reference_wrapper}, then \tcode{V}$_i$ in \tcode{VTypes} is \tcode{U$_i$::type\&}, -otherwise \tcode{V}$_i$ is \tcode{U}$_i$. +Let \tcode{VTypes...} be \tcode{unwrap_ref_decay_t...}. \pnum \returns \tcode{tuple(std::forward(t)...)}. @@ -13033,6 +13028,8 @@ \rSec2[functional.syn]{Header \tcode{} synopsis} \indexhdr{functional}% +\indexlibrary{\idxcode{unwrap_ref_decay}}% +\indexlibrary{\idxcode{unwrap_ref_decay_t}}% \begin{codeblock} namespace std { // \ref{func.invoke}, invoke @@ -13051,6 +13048,10 @@ template reference_wrapper ref(reference_wrapper) noexcept; template reference_wrapper cref(reference_wrapper) noexcept; + template struct unwrap_reference; + template struct unwrap_ref_decay : unwrap_reference> {}; + template using unwrap_ref_decay_t = typename unwrap_ref_decay::type; + // \ref{arithmetic.operations}, arithmetic operations template struct plus; template struct minus; @@ -13407,7 +13408,6 @@ \pnum\returns The stored reference. \end{itemdescr} - \rSec3[refwrap.invoke]{Invocation} \indexlibrarymember{operator()}{reference_wrapper}% @@ -13460,6 +13460,20 @@ \pnum\returns \tcode{cref(t.get())}. \end{itemdescr} +\rSec3[refwrap.unwrapref]{Transformation type trait \tcode{unwrap_reference}} + +\indexlibrary{\idxcode{unwrap_reference}}% +\begin{itemdecl} +template + struct unwrap_reference; +\end{itemdecl} + +\pnum +If \tcode{T} is +a specialization \tcode{reference_wrapper} for some type \tcode{X}, +the member typedef \tcode{type} of \tcode{unwrap_reference} is \tcode{X\&}, +otherwise it is \tcode{T}. + \rSec2[arithmetic.operations]{Arithmetic operations} \pnum From 92326665186c9c4e29f058f5b8d0ae5ea9814465 Mon Sep 17 00:00:00 2001 From: Jens Maurer Date: Sat, 17 Nov 2018 15:29:01 +0100 Subject: [PATCH 2/2] [pairs.spec,tuple.creation] Simplify description by inlining unwrap_ref_decay_t into its point of use. --- source/utilities.tex | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/source/utilities.tex b/source/utilities.tex index 15333cc800..56d9e51219 100644 --- a/source/utilities.tex +++ b/source/utilities.tex @@ -852,14 +852,16 @@ \indexlibrary{\idxcode{make_pair}}% \begin{itemdecl} template - constexpr pair make_pair(T1&& x, T2&& y); + constexpr pair, unwrap_ref_decay_t> make_pair(T1&& x, T2&& y); \end{itemdecl} \begin{itemdescr} -Let \tcode{Vi} be \tcode{unwrap_ref_decay_t}. - \pnum -\returns \tcode{pair(std::forward(x), std::forward(y))}. +\returns +\begin{codeblock} +pair, + unwrap_ref_decay_t>(std::forward(x), std::forward(y)) +\end{codeblock} \end{itemdescr} \pnum @@ -997,7 +999,7 @@ inline constexpr @\unspec@ ignore; template - constexpr tuple make_tuple(TTypes&&...); + constexpr tuple...> make_tuple(TTypes&&...); template constexpr tuple forward_as_tuple(TTypes&&...) noexcept; @@ -1608,15 +1610,12 @@ \indexlibrary{\idxcode{tuple}!\idxcode{make_tuple}}% \begin{itemdecl} template - constexpr tuple make_tuple(TTypes&&... t); + constexpr tuple...> make_tuple(TTypes&&... t); \end{itemdecl} \begin{itemdescr} \pnum -Let \tcode{VTypes...} be \tcode{unwrap_ref_decay_t...}. - -\pnum -\returns \tcode{tuple(std::forward(t)...)}. +\returns \tcode{tuple...>(std::forward(t)...)}. \pnum \begin{example}