Skip to content

P0318R1 unwrap_ref_decay and unwrap_reference #2471

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 26, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 29 additions & 16 deletions source/utilities.tex
Original file line number Diff line number Diff line change
Expand Up @@ -852,16 +852,16 @@
\indexlibrary{\idxcode{make_pair}}%
\begin{itemdecl}
template<class T1, class T2>
constexpr pair<V1, V2> make_pair(T1&& x, T2&& y);
constexpr pair<unwrap_ref_decay_t<T1>, unwrap_ref_decay_t<T2>> make_pair(T1&& x, T2&& y);
\end{itemdecl}

\begin{itemdescr}
\pnum
\returns \tcode{pair<V1, V2>(std::forward<T1>(x), std::forward<T2>(y))},
where \tcode{V1} and \tcode{V2} are determined as follows: Let \tcode{Ui} be
\tcode{decay_t<Ti>} 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
\begin{codeblock}
pair<unwrap_ref_decay_t<T1>,
unwrap_ref_decay_t<T2>>(std::forward<T1>(x), std::forward<T2>(y))
\end{codeblock}
\end{itemdescr}

\pnum
Expand Down Expand Up @@ -999,7 +999,7 @@
inline constexpr @\unspec@ ignore;

template<class... TTypes>
constexpr tuple<VTypes...> make_tuple(TTypes&&...);
constexpr tuple<unwrap_ref_decay_t<TTypes>...> make_tuple(TTypes&&...);

template<class... TTypes>
constexpr tuple<TTypes&&...> forward_as_tuple(TTypes&&...) noexcept;
Expand Down Expand Up @@ -1610,18 +1610,12 @@
\indexlibrary{\idxcode{tuple}!\idxcode{make_tuple}}%
\begin{itemdecl}
template<class... TTypes>
constexpr tuple<VTypes...> make_tuple(TTypes&&... t);
constexpr tuple<unwrap_ref_decay_t<TTypes>...> make_tuple(TTypes&&... t);
\end{itemdecl}

\begin{itemdescr}
\pnum
The pack \tcode{VTypes} is defined as follows. Let \tcode{U}$_i$ be \tcode{decay_t<T$_i$>} 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$.

\pnum
\returns \tcode{tuple<VTypes...>(std::forward<TTypes>(t)...)}.
\returns \tcode{tuple<unwrap_ref_decay_t<TTypes>...>(std::forward<TTypes>(t)...)}.

\pnum
\begin{example}
Expand Down Expand Up @@ -13033,6 +13027,8 @@
\rSec2[functional.syn]{Header \tcode{<functional>} synopsis}

\indexhdr{functional}%
\indexlibrary{\idxcode{unwrap_ref_decay}}%
\indexlibrary{\idxcode{unwrap_ref_decay_t}}%
\begin{codeblock}
namespace std {
// \ref{func.invoke}, invoke
Expand All @@ -13051,6 +13047,10 @@
template<class T> reference_wrapper<T> ref(reference_wrapper<T>) noexcept;
template<class T> reference_wrapper<const T> cref(reference_wrapper<T>) noexcept;

template<class T> struct unwrap_reference;
template<class T> struct unwrap_ref_decay : unwrap_reference<decay_t<T>> {};
template<class T> using unwrap_ref_decay_t = typename unwrap_ref_decay<T>::type;

// \ref{arithmetic.operations}, arithmetic operations
template<class T = void> struct plus;
template<class T = void> struct minus;
Expand Down Expand Up @@ -13407,7 +13407,6 @@
\pnum\returns The stored reference.
\end{itemdescr}


\rSec3[refwrap.invoke]{Invocation}

\indexlibrarymember{operator()}{reference_wrapper}%
Expand Down Expand Up @@ -13460,6 +13459,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<class T>
struct unwrap_reference;
\end{itemdecl}

\pnum
If \tcode{T} is
a specialization \tcode{reference_wrapper<X>} for some type \tcode{X},
the member typedef \tcode{type} of \tcode{unwrap_reference<T>} is \tcode{X\&},
otherwise it is \tcode{T}.

\rSec2[arithmetic.operations]{Arithmetic operations}

\pnum
Expand Down