Skip to content

Commit

Permalink
NB US-15 (C++14 CD): Use the _t form of type traits.
Browse files Browse the repository at this point in the history
Throughout the text, replace uses of traits of the form

  typename decay<T>::type

with the shorter form

  decay_t<T>

using the alias templates introduced in the CD. Do this for all type
traits with such aliases.

Closes #178.
  • Loading branch information
sdutoit committed Oct 14, 2013
1 parent afd1e4f commit 59d041e
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 57 deletions.
14 changes: 6 additions & 8 deletions source/threads.tex
Expand Up @@ -276,7 +276,7 @@
result, where \tcode{decay_copy} is defined as follows:

\begin{codeblock}
template <class T> typename decay<T>::type decay_copy(T&& v)
template <class T> decay_t<T> decay_copy(T&& v)
{ return std::forward<T>(v); }
\end{codeblock}

Expand Down Expand Up @@ -3506,10 +3506,10 @@
struct uses_allocator<packaged_task<R>, Alloc>;

template <class F, class... Args>
future<typename result_of<typename decay<F>::type(typename decay<Args>::type...)>::type>
future<result_of_t<decay_t<F>(decay_t<Args>...)>>
async(F&& f, Args&&... args);
template <class F, class... Args>
future<typename result_of<typename decay<F>::type(typename decay<Args>::type...)>::type>
future<result_of_t<decay_t<F>(decay_t<Args>...)>>
async(launch policy, F&& f, Args&&... args);
}
\end{codeblock}
Expand Down Expand Up @@ -4617,11 +4617,9 @@
\indexlibrary{\idxcode{async}}%
\begin{itemdecl}
template <class F, class... Args>
future<typename result_of<typename decay<F>::type(typename decay<Args>::type...)>::type>
async(F&& f, Args&&... args);
future<result_of_t<decay_t<F>(decay_t<Args>...)>> async(F&& f, Args&&... args);
template <class F, class... Args>
future<typename result_of<typename decay<F>::type(typename decay<Args>::type...)>::type>
async(launch policy, F&& f, Args&&... args);
future<result_of_t<decay_t<F>(decay_t<Args>...)>> async(launch policy, F&& f, Args&&... args);
\end{itemdecl}

\begin{itemdescr}
Expand Down Expand Up @@ -4694,7 +4692,7 @@

\pnum
\returns An object of type
\tcode{future<typename result_of<typename decay<F>::type(typename de\-cay<Args>::type...)>::type>} that refers
\tcode{future<result_of_t<decay_t<F>(decay_t<Args>...)>{>}} that refers
to the shared state created by this call to \tcode{async}.
\enternote If a future obtained from std::async is moved outside the local scope,
other code that uses the future must be aware that the future’s destructor may
Expand Down
98 changes: 49 additions & 49 deletions source/utilities.tex
Expand Up @@ -61,19 +61,19 @@

// \ref{forward}, forward/move:
template <class T>
constexpr T&& forward(typename remove_reference<T>::type& t) noexcept;
constexpr T&& forward(remove_reference_t<T>& t) noexcept;
template <class T>
constexpr T&& forward(typename remove_reference<T>::type&& t) noexcept;
constexpr T&& forward(remove_reference_t<T>&& t) noexcept;
template <class T>
constexpr typename remove_reference<T>::type&& move(T&&) noexcept;
constexpr remove_reference_t<T>&& move(T&&) noexcept;
template <class T>
constexpr typename conditional<
constexpr conditional_t<
!is_nothrow_move_constructible<T>::value && is_copy_constructible<T>::value,
const T&, T&&>::type move_if_noexcept(T& x) noexcept;
const T&, T&&> move_if_noexcept(T& x) noexcept;

// \ref{declval}, declval:
template <class T>
typename add_rvalue_reference<T>::type declval() noexcept; // as unevaluated operand
add_rvalue_reference_t<T> declval() noexcept; // as unevaluated operand

// \ref{pairs}, pairs:
template <class T1, class T2> struct pair;
Expand Down Expand Up @@ -293,8 +293,8 @@

\indexlibrary{\idxcode{forward}}%
\begin{itemdecl}
template <class T> constexpr T&& forward(typename remove_reference<T>::type& t) noexcept;
template <class T> constexpr T&& forward(typename remove_reference<T>::type&& t) noexcept;
template <class T> constexpr T&& forward(remove_reference_t<T>& t) noexcept;
template <class T> constexpr T&& forward(remove_reference_t<T>&& t) noexcept;
\end{itemdecl}

\begin{itemdescr}
Expand Down Expand Up @@ -338,13 +338,13 @@

\indexlibrary{\idxcode{move}}%
\begin{itemdecl}
template <class T> constexpr typename remove_reference<T>::type&& move(T&& t) noexcept;
template <class T> constexpr remove_reference_t<T>&& move(T&& t) noexcept;
\end{itemdecl}

\begin{itemdescr}
\pnum
\returns
\tcode{static_cast<typename remove_reference<T>::type\&\&>(t)}.
\tcode{static_cast<remove_reference_t<T>\&\&>(t)}.

\pnum
\enterexample
Expand Down Expand Up @@ -383,9 +383,9 @@

\indexlibrary{\idxcode{move_if_noexcept}}%
\begin{itemdecl}
template <class T> constexpr typename conditional<
template <class T> constexpr conditional_t<
!is_nothrow_move_constructible<T>::value && is_copy_constructible<T>::value,
const T&, T&&>::type move_if_noexcept(T& x) noexcept;
const T&, T&&> move_if_noexcept(T& x) noexcept;
\end{itemdecl}

\begin{itemdescr}
Expand All @@ -402,7 +402,7 @@
\indexlibrary{\idxcode{declval}}%
\begin{itemdecl}
template <class T>
typename add_rvalue_reference<T>::type declval() noexcept; // as unevaluated operand
add_rvalue_reference_t<T> declval() noexcept; // as unevaluated operand
\end{itemdecl}

\begin{itemdescr}
Expand Down Expand Up @@ -865,7 +865,7 @@
\indexlibrary{\idxcode{get}!\idxcode{pair}}%
\begin{itemdecl}
template<size_t I, class T1, class T2>
constexpr typename tuple_element<I, std::pair<T1, T2> >::type&
constexpr tuple_element_t<I, std::pair<T1, T2> >&
get(pair<T1, T2>&) noexcept;
template<size_t I, class T1, class T2>
constexpr const typename tuple_element<I, std::pair<T1, T2> >::type&
Expand Down Expand Up @@ -4503,7 +4503,7 @@
unique_ptr& operator=(nullptr_t) noexcept;

// \ref{unique.ptr.single.observers}, observers
typename add_lvalue_reference<T>::type operator*() const;
add_lvalue_reference_t<T> operator*() const;
pointer operator->() const noexcept;
pointer get() const noexcept;
deleter_type& get_deleter() noexcept;
Expand Down Expand Up @@ -4893,7 +4893,7 @@
\indexlibrary{\idxcode{operator*}!\idxcode{unique_ptr}}
\indexlibrary{\idxcode{unique_ptr}!\idxcode{operator*}}
\begin{itemdecl}
typename add_lvalue_reference<T>::type operator*() const;
add_lvalue_reference_t<T> operator*() const;
\end{itemdecl}

\begin{itemdescr}
Expand Down Expand Up @@ -5160,7 +5160,7 @@
\remarks This function shall not participate in overload resolution unless \tcode{T} is an array of unknown bound.

\pnum
\returns \tcode{unique_ptr<T>(new typename remove_extent<T>::type[n]())}.
\returns \tcode{unique_ptr<T>(new remove_extent_t<T>[n]())}.

\end{itemdescr}

Expand Down Expand Up @@ -7282,7 +7282,7 @@

// invocation
template <class... ArgTypes>
typename result_of<T&(ArgTypes&&...)>::type
result_of_t<T&(ArgTypes&&...)>
operator() (ArgTypes&&...) const;
};
}
Expand Down Expand Up @@ -7405,7 +7405,7 @@
\indexlibrary{\idxcode{operator()}!\idxcode{reference_wrapper}}%
\begin{itemdecl}
template <class... ArgTypes>
typename result_of<T&(ArgTypes&&... )>::type
result_of_t<T&(ArgTypes&&... )>
operator()(ArgTypes&&... args) const;
\end{itemdecl}

Expand Down Expand Up @@ -9614,7 +9614,7 @@
Given the following function prototype:
\begin{codeblock}
template <class T>
typename add_rvalue_reference<T>::type create() noexcept;
add_rvalue_reference_t<T> create() noexcept;
\end{codeblock}

the predicate condition for a template specialization
Expand Down Expand Up @@ -9768,7 +9768,7 @@

\begin{codeblock}
template <class T>
typename add_rvalue_reference<T>::type create() noexcept;
add_rvalue_reference_t<T> create() noexcept;
\end{codeblock}

the predicate condition for a template specialization \tcode{is_convertible<From, To>}
Expand Down Expand Up @@ -9851,7 +9851,7 @@
struct add_cv;} &
The member typedef \tcode{type} shall name
the same type as
\tcode{add_const<typename add_volatile<T>::type>::type}. \\
\tcode{add_const_t<add_volatile_t<T>{>}}. \\
\end{libreqtab2a}

\rSec3[meta.trans.ref]{Reference modifications}
Expand Down Expand Up @@ -10137,7 +10137,7 @@

template <class T, class U, class... V>
struct common_type<T, U, V...> {
typedef typename common_type<typename common_type<T, U>::type, V...>::type type;
typedef common_type_t<common_type_t<T, U>, V...> type;
};
\end{codeblock}

Expand Down Expand Up @@ -10433,28 +10433,28 @@

// \ref{time.duration.nonmember}, duration arithmetic
template <class Rep1, class Period1, class Rep2, class Period2>
typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
common_type_t<duration<Rep1, Period1>, duration<Rep2, Period2>>
constexpr operator+(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
template <class Rep1, class Period1, class Rep2, class Period2>
typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
common_type_t<duration<Rep1, Period1>, duration<Rep2, Period2>>
constexpr operator-(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
template <class Rep1, class Period, class Rep2>
duration<typename common_type<Rep1, Rep2>::type, Period>
duration<common_type_t<Rep1, Rep2>, Period>
constexpr operator*(const duration<Rep1, Period>& d, const Rep2& s);
template <class Rep1, class Rep2, class Period>
duration<typename common_type<Rep1, Rep2>::type, Period>
duration<common_type_t<Rep1, Rep2>, Period>
constexpr operator*(const Rep1& s, const duration<Rep2, Period>& d);
template <class Rep1, class Period, class Rep2>
duration<typename common_type<Rep1, Rep2>::type, Period>
duration<common_type_t<Rep1, Rep2>, Period>
constexpr operator/(const duration<Rep1, Period>& d, const Rep2& s);
template <class Rep1, class Period1, class Rep2, class Period2>
typename common_type<Rep1, Rep2>::type
common_type_t<Rep1, Rep2>
constexpr operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
template <class Rep1, class Period, class Rep2>
duration<typename common_type<Rep1, Rep2>::type, Period>
duration<common_type_t<Rep1, Rep2>, Period>
constexpr operator%(const duration<Rep1, Period>& d, const Rep2& s);
template <class Rep1, class Period1, class Rep2, class Period2>
typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
common_type_t<duration<Rep1, Period1>, duration<Rep2, Period2>>
constexpr operator%(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);

// \ref{time.duration.comparisons}, duration comparisons
Expand Down Expand Up @@ -10491,16 +10491,16 @@

// \ref{time.point.nonmember}, time_point arithmetic
template <class Clock, class Duration1, class Rep2, class Period2>
constexpr time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
constexpr time_point<Clock, common_type_t<Duration1, duration<Rep2, Period2>>>
operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
template <class Rep1, class Period1, class Clock, class Duration2>
constexpr time_point<Clock, typename common_type<duration<Rep1, Period1>, Duration2>::type>
constexpr time_point<Clock, common_type_t<duration<Rep1, Period1>, Duration2>>
operator+(const duration<Rep1, Period1>& lhs, const time_point<Clock, Duration2>& rhs);
template <class Clock, class Duration1, class Rep2, class Period2>
constexpr time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
constexpr time_point<Clock, common_type_t<Duration1, duration<Rep2, Period2>>>
operator-(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
template <class Clock, class Duration1, class Duration2>
constexpr typename common_type<Duration1, Duration2>::type
constexpr common_type_t<Duration1, Duration2>
operator-(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);

// \ref{time.point.comparisons} time_point comparisons
Expand Down Expand Up @@ -10737,7 +10737,7 @@
\begin{itemdecl}
template <class Rep1, class Period1, class Rep2, class Period2>
struct common_type<chrono::duration<Rep1, Period1>, chrono::duration<Rep2, Period2>> {
typedef chrono::duration<typename common_type<Rep1, Rep2>::type, @\seebelow@> type;
typedef chrono::duration<common_type_t<Rep1, Rep2>, @\seebelow@> type;
};
\end{itemdecl}

Expand All @@ -10761,7 +10761,7 @@
\begin{itemdecl}
template <class Clock, class Duration1, class Duration2>
struct common_type<chrono::time_point<Clock, Duration1>, chrono::time_point<Clock, Duration2>> {
typedef chrono::time_point<Clock, typename common_type<Duration1, Duration2>::type> type;
typedef chrono::time_point<Clock, common_type_t<Duration1, Duration2>> type;
};
\end{itemdecl}

Expand Down Expand Up @@ -11132,7 +11132,7 @@
\indexlibrary{\idxcode{common_type}}%
\begin{itemdecl}
template <class Rep1, class Period1, class Rep2, class Period2>
constexpr typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2> >::type
constexpr common_type_t<duration<Rep1, Period1>, duration<Rep2, Period2>>
operator+(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
\end{itemdecl}

Expand All @@ -11144,7 +11144,7 @@
\indexlibrary{\idxcode{common_type}}%
\begin{itemdecl}
template <class Rep1, class Period1, class Rep2, class Period2>
constexpr typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2> >::type
constexpr common_type_t<duration<Rep1, Period1>, duration<Rep2, Period2>>
operator-(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
\end{itemdecl}

Expand All @@ -11157,7 +11157,7 @@
\indexlibrary{\idxcode{duration}!\idxcode{operator*}}%
\begin{itemdecl}
template <class Rep1, class Period, class Rep2>
constexpr duration<typename common_type<Rep1, Rep2>::type, Period>
constexpr duration<common_type_t<Rep1, Rep2>, Period>
operator*(const duration<Rep1, Period>& d, const Rep2& s);
\end{itemdecl}

Expand All @@ -11174,7 +11174,7 @@
\indexlibrary{\idxcode{duration}!\idxcode{operator*}}%
\begin{itemdecl}
template <class Rep1, class Rep2, class Period>
constexpr duration<typename common_type<Rep1, Rep2>::type, Period>
constexpr duration<common_type_t<Rep1, Rep2>, Period>
operator*(const Rep1& s, const duration<Rep2, Period>& d);
\end{itemdecl}

Expand All @@ -11191,7 +11191,7 @@
\indexlibrary{\idxcode{duration}!\idxcode{operator/}}%
\begin{itemdecl}
template <class Rep1, class Period, class Rep2>
constexpr duration<typename common_type<Rep1, Rep2>::type, Period>
constexpr duration<common_type_t<Rep1, Rep2>, Period>
operator/(const duration<Rep1, Period>& d, const Rep2& s);
\end{itemdecl}

Expand All @@ -11209,7 +11209,7 @@
\indexlibrary{\idxcode{duration}!\idxcode{operator/}}%
\begin{itemdecl}
template <class Rep1, class Period1, class Rep2, class Period2>
constexpr typename common_type<Rep1, Rep2>::type
constexpr common_type_t<Rep1, Rep2>
operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
\end{itemdecl}

Expand All @@ -11222,7 +11222,7 @@
\indexlibrary{\idxcode{duration}!\idxcode{operator\%}}%
\begin{itemdecl}
template <class Rep1, class Period, class Rep2>
constexpr duration<typename common_type<Rep1, Rep2>::type, Period>
constexpr duration<common_type_t<Rep1, Rep2>, Period>
operator%(const duration<Rep1, Period>& d, const Rep2& s);
\end{itemdecl}

Expand All @@ -11240,7 +11240,7 @@
\indexlibrary{\idxcode{duration}!\idxcode{operator\%}}%
\begin{itemdecl}
template <class Rep1, class Period1, class Rep2, class Period2>
constexpr typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
constexpr common_type_t<duration<Rep1, Period1>, duration<Rep2, Period2>>
operator%(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
\end{itemdecl}

Expand Down Expand Up @@ -11637,7 +11637,7 @@
\indexlibrary{\idxcode{duration}!\idxcode{operator+}}%
\begin{itemdecl}
template <class Clock, class Duration1, class Rep2, class Period2>
constexpr time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
constexpr time_point<Clock, common_type_t<Duration1, duration<Rep2, Period2>>>
operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
\end{itemdecl}

Expand All @@ -11652,7 +11652,7 @@
\indexlibrary{\idxcode{duration}!\idxcode{operator+}}%
\begin{itemdecl}
template <class Rep1, class Period1, class Clock, class Duration2>
constexpr time_point<Clock, typename common_type<duration<Rep1, Period1>, Duration2>::type>
constexpr time_point<Clock, common_type_t<duration<Rep1, Period1>, Duration2>>
operator+(const duration<Rep1, Period1>& lhs, const time_point<Clock, Duration2>& rhs);
\end{itemdecl}

Expand All @@ -11667,7 +11667,7 @@
\indexlibrary{\idxcode{duration}!\idxcode{operator-}}%
\begin{itemdecl}
template <class Clock, class Duration1, class Rep2, class Period2>
constexpr time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
constexpr time_point<Clock, common_type_t<Duration1, duration<Rep2, Period2>>>
operator-(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
\end{itemdecl}

Expand All @@ -11680,7 +11680,7 @@
\indexlibrary{\idxcode{time_point}!\idxcode{operator-}}%
\begin{itemdecl}
template <class Clock, class Duration1, class Duration2>
constexpr typename common_type<Duration1, Duration2>::type
constexpr common_type_t<Duration1, Duration2>
operator-(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
\end{itemdecl}

Expand Down

0 comments on commit 59d041e

Please sign in to comment.