forked from OSchip/llvm-project
Implement LWG Paper n3887: Consistent Metafunction Aliases. This adds std::tuple_element_t<> as an alias for tuple_element<>::type. Clean up the synopsis for tuple_element in <utility> as well.
llvm-svn: 202673
This commit is contained in:
parent
06965c1fd0
commit
05c8dad230
|
@ -82,13 +82,15 @@ template <class T> class tuple_size; // undefined
|
|||
template <class... T> class tuple_size<tuple<T...>>;
|
||||
template <intsize_t I, class T> class tuple_element; // undefined
|
||||
template <intsize_t I, class... T> class tuple_element<I, tuple<T...>>;
|
||||
template <size_t _Ip, class ..._Tp>
|
||||
using tuple_element_t = typename tuple_element <_Ip, _Tp...>::type; // C++14
|
||||
|
||||
// 20.4.1.5, element access:
|
||||
template <intsize_t I, class... T>
|
||||
typename tuple_element<I, tuple<T...>>::type&
|
||||
get(tuple<T...>&) noexcept; // constexpr in C++14
|
||||
template <intsize_t I, class... T>
|
||||
typename tuple_element<I, tuple<T...>>::type const&
|
||||
typename const tuple_element<I, tuple<T...>>::type &
|
||||
get(const tuple<T...>&) noexcept; // constexpr in C++14
|
||||
template <intsize_t I, class... T>
|
||||
typename tuple_element<I, tuple<T...>>::type&&
|
||||
|
@ -152,6 +154,11 @@ public:
|
|||
typedef typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type;
|
||||
};
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <size_t _Ip, class ..._Tp>
|
||||
using tuple_element_t = typename tuple_element <_Ip, _Tp...>::type;
|
||||
#endif
|
||||
|
||||
// __tuple_leaf
|
||||
|
||||
template <size_t _Ip, class _Hp, bool=is_empty<_Hp>::value
|
||||
|
|
|
@ -101,30 +101,30 @@ constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
|
|||
template <class T> class tuple_size;
|
||||
template <size_t I, class T> class tuple_element;
|
||||
|
||||
template <class T1, class T2> struct tuple_size<std::pair<T1, T2> >;
|
||||
template <class T1, class T2> struct tuple_element<0, std::pair<T1, T2> >;
|
||||
template <class T1, class T2> struct tuple_element<1, std::pair<T1, T2> >;
|
||||
template <class T1, class T2> struct tuple_size<pair<T1, T2> >;
|
||||
template <class T1, class T2> struct tuple_element<0, pair<T1, T2> >;
|
||||
template <class T1, class T2> struct tuple_element<1, pair<T1, T2> >;
|
||||
|
||||
template<size_t I, class T1, class T2>
|
||||
typename tuple_element<I, std::pair<T1, T2> >::type&
|
||||
get(std::pair<T1, T2>&) noexcept; // constexpr in C++14
|
||||
typename tuple_element<I, pair<T1, T2> >::type&
|
||||
get(pair<T1, T2>&) noexcept; // constexpr in C++14
|
||||
|
||||
template<size_t I, class T1, class T2>
|
||||
const typename const tuple_element<I, std::pair<T1, T2> >::type&
|
||||
get(const std::pair<T1, T2>&) noexcept; // constexpr in C++14
|
||||
const typename const tuple_element<I, pair<T1, T2> >::type&
|
||||
get(const pair<T1, T2>&) noexcept; // constexpr in C++14
|
||||
|
||||
template<size_t I, class T1, class T2>
|
||||
typename tuple_element<I, std::pair<T1, T2> >::type&&
|
||||
get(std::pair<T1, T2>&&) noexcept; // constexpr in C++14
|
||||
typename tuple_element<I, pair<T1, T2> >::type&&
|
||||
get(pair<T1, T2>&&) noexcept; // constexpr in C++14
|
||||
|
||||
template<class T1, class T2>
|
||||
constexpr T1& get(std::pair<T1, T2>&) noexcept; // C++14
|
||||
constexpr T1& get(pair<T1, T2>&) noexcept; // C++14
|
||||
|
||||
template<size_t I, class T1, class T2>
|
||||
constexpr T1 const& get(std::pair<T1, T2> const &) noexcept; // C++14
|
||||
constexpr T1 const& get(pair<T1, T2> const &) noexcept; // C++14
|
||||
|
||||
template<size_t I, class T1, class T2>
|
||||
constexpr T1&& get(std::pair<T1, T2>&&) noexcept; // C++14
|
||||
constexpr T1&& get(pair<T1, T2>&&) noexcept; // C++14
|
||||
|
||||
// C++14
|
||||
|
||||
|
|
|
@ -28,7 +28,14 @@ void test()
|
|||
static_assert((std::is_same<typename std::tuple_element<N, const T>::type, const U>::value), "");
|
||||
static_assert((std::is_same<typename std::tuple_element<N, volatile T>::type, volatile U>::value), "");
|
||||
static_assert((std::is_same<typename std::tuple_element<N, const volatile T>::type, const volatile U>::value), "");
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
static_assert((std::is_same<typename std::tuple_element_t<N, T>, U>::value), "");
|
||||
static_assert((std::is_same<typename std::tuple_element_t<N, const T>, const U>::value), "");
|
||||
static_assert((std::is_same<typename std::tuple_element_t<N, volatile T>, volatile U>::value), "");
|
||||
static_assert((std::is_same<typename std::tuple_element_t<N, const volatile T>, const volatile U>::value), "");
|
||||
#endif
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<std::tuple<int>, 0, int>();
|
||||
|
|
|
@ -100,7 +100,7 @@
|
|||
<tr><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
|
||||
<tr><td><a href="http://wiki.edg.com/twiki/pub/Wg21issaquah/FormalMotions/N3924_rand-note-v2.pdf">3924</a></td><td>LWG</td><td>Discouraging rand() in C++14</td><td>Issaquah</td><td></td><td></td></tr>
|
||||
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3887">3887</a></td><td>LWG</td><td>Consistent Metafunction Aliases</td><td>Issaquah</td><td></td><td></td></tr>
|
||||
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3887">3887</a></td><td>LWG</td><td>Consistent Metafunction Aliases</td><td>Issaquah</td><td></td><td>Complete</td></tr>
|
||||
|
||||
<!-- <tr><td></td><td></td><td></td><td></td><td></td><td></td></tr> -->
|
||||
</table>
|
||||
|
|
Loading…
Reference in New Issue