[libcxx-commits] [libcxx] r357411 - [libc++] Declare std::tuple_element as struct instead of class
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Apr 1 09:39:35 PDT 2019
Author: ldionne
Date: Mon Apr 1 09:39:34 2019
New Revision: 357411
URL: http://llvm.org/viewvc/llvm-project?rev=357411&view=rev
Log:
[libc++] Declare std::tuple_element as struct instead of class
Similarly to https://reviews.llvm.org/rL350972, this revision changes
std::tuple_element from class to struct.
Fixes PR41331.
Thanks to Jan Wilken Dörrie for the patch.
Differential Revision: https://reviews.llvm.org/D60069
Modified:
libcxx/trunk/include/__tuple
libcxx/trunk/include/array
libcxx/trunk/include/span
libcxx/trunk/include/tuple
libcxx/trunk/include/utility
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple.include.array.pass.cpp
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.fail.cpp
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp
Modified: libcxx/trunk/include/__tuple
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__tuple?rev=357411&r1=357410&r2=357411&view=diff
==============================================================================
--- libcxx/trunk/include/__tuple (original)
+++ libcxx/trunk/include/__tuple Mon Apr 1 09:39:34 2019
@@ -53,26 +53,23 @@ template <class _Tp> struct _LIBCPP_TEMP
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_size<const volatile _Tp> : public tuple_size<_Tp> {};
#endif
-template <size_t _Ip, class _Tp> class _LIBCPP_TEMPLATE_VIS tuple_element;
+template <size_t _Ip, class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_element;
template <size_t _Ip, class _Tp>
-class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const _Tp>
+struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const _Tp>
{
-public:
typedef typename add_const<typename tuple_element<_Ip, _Tp>::type>::type type;
};
template <size_t _Ip, class _Tp>
-class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, volatile _Tp>
+struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, volatile _Tp>
{
-public:
typedef typename add_volatile<typename tuple_element<_Ip, _Tp>::type>::type type;
};
template <size_t _Ip, class _Tp>
-class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const volatile _Tp>
+struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const volatile _Tp>
{
-public:
typedef typename add_cv<typename tuple_element<_Ip, _Tp>::type>::type type;
};
@@ -281,9 +278,8 @@ using __type_pack_element = typename dec
#endif
template <size_t _Ip, class ..._Types>
-class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, __tuple_types<_Types...>>
+struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, __tuple_types<_Types...>>
{
-public:
static_assert(_Ip < sizeof...(_Types), "tuple_element index out of range");
typedef __type_pack_element<_Ip, _Types...> type;
};
@@ -456,9 +452,8 @@ struct __tuple_assignable<_Tp, _Up, true
template <size_t _Ip, class ..._Tp>
-class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, tuple<_Tp...> >
+struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, tuple<_Tp...> >
{
-public:
typedef typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type;
};
Modified: libcxx/trunk/include/array
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/array?rev=357411&r1=357410&r2=357411&view=diff
==============================================================================
--- libcxx/trunk/include/array (original)
+++ libcxx/trunk/include/array Mon Apr 1 09:39:34 2019
@@ -91,7 +91,7 @@ template <class T, size_t N >
void swap(array<T,N>& x, array<T,N>& y) noexcept(noexcept(x.swap(y))); // C++17
template <class T> struct tuple_size;
-template <size_t I, class T> class tuple_element;
+template <size_t I, class T> struct tuple_element;
template <class T, size_t N> struct tuple_size<array<T, N>>;
template <size_t I, class T, size_t N> struct tuple_element<I, array<T, N>>;
template <size_t I, class T, size_t N> T& get(array<T, N>&) noexcept; // constexpr in C++14
@@ -433,10 +433,9 @@ struct _LIBCPP_TEMPLATE_VIS tuple_size<a
: public integral_constant<size_t, _Size> {};
template <size_t _Ip, class _Tp, size_t _Size>
-class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, array<_Tp, _Size> >
+struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, array<_Tp, _Size> >
{
static_assert(_Ip < _Size, "Index out of bounds in std::tuple_element<> (std::array)");
-public:
typedef _Tp type;
};
Modified: libcxx/trunk/include/span
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/span?rev=357411&r1=357410&r2=357411&view=diff
==============================================================================
--- libcxx/trunk/include/span (original)
+++ libcxx/trunk/include/span Mon Apr 1 09:39:34 2019
@@ -531,11 +531,10 @@ struct _LIBCPP_TEMPLATE_VIS tuple_size<s
template <size_t _Ip, class _Tp, size_t _Size>
-class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, span<_Tp, _Size>>
+struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, span<_Tp, _Size>>
{
static_assert( dynamic_extent != _Size, "std::tuple_element<> not supported for std::span<T, dynamic_extent>");
static_assert(_Ip < _Size, "Index out of bounds in std::tuple_element<> (std::span)");
-public:
typedef _Tp type;
};
Modified: libcxx/trunk/include/tuple
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/tuple?rev=357411&r1=357410&r2=357411&view=diff
==============================================================================
--- libcxx/trunk/include/tuple (original)
+++ libcxx/trunk/include/tuple Mon Apr 1 09:39:34 2019
@@ -87,8 +87,8 @@ template <class T> struct tuple_size; //
template <class... T> struct tuple_size<tuple<T...>>;
template <class T>
inline constexpr size_t tuple_size_v = tuple_size<T>::value; // C++17
-template <size_t I, class T> class tuple_element; // undefined
-template <size_t I, class... T> class tuple_element<I, tuple<T...>>;
+template <size_t I, class T> struct tuple_element; // undefined
+template <size_t I, class... T> struct tuple_element<I, tuple<T...>>;
template <size_t I, class T>
using tuple_element_t = typename tuple_element <I, T>::type; // C++14
Modified: libcxx/trunk/include/utility
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/utility?rev=357411&r1=357410&r2=357411&view=diff
==============================================================================
--- libcxx/trunk/include/utility (original)
+++ libcxx/trunk/include/utility Mon Apr 1 09:39:34 2019
@@ -103,7 +103,7 @@ struct piecewise_construct_t { };
inline constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
template <class T> struct tuple_size;
-template <size_t I, class T> class tuple_element;
+template <size_t I, class T> struct tuple_element;
template <class T1, class T2> struct tuple_size<pair<T1, T2> >;
template <class T1, class T2> struct tuple_element<0, pair<T1, T2> >;
@@ -687,22 +687,20 @@ template <class _T1, class _T2>
: public integral_constant<size_t, 2> {};
template <size_t _Ip, class _T1, class _T2>
-class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, pair<_T1, _T2> >
+struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, pair<_T1, _T2> >
{
static_assert(_Ip < 2, "Index out of bounds in std::tuple_element<std::pair<T1, T2>>");
};
template <class _T1, class _T2>
-class _LIBCPP_TEMPLATE_VIS tuple_element<0, pair<_T1, _T2> >
+struct _LIBCPP_TEMPLATE_VIS tuple_element<0, pair<_T1, _T2> >
{
-public:
typedef _T1 type;
};
template <class _T1, class _T2>
-class _LIBCPP_TEMPLATE_VIS tuple_element<1, pair<_T1, _T2> >
+struct _LIBCPP_TEMPLATE_VIS tuple_element<1, pair<_T1, _T2> >
{
-public:
typedef _T2 type;
};
Modified: libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple.include.array.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple.include.array.pass.cpp?rev=357411&r1=357410&r2=357411&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple.include.array.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple.include.array.pass.cpp Mon Apr 1 09:39:34 2019
@@ -11,9 +11,8 @@
// template <class... Types> class tuple;
// template <size_t I, class... Types>
-// class tuple_element<I, tuple<Types...> >
+// struct tuple_element<I, tuple<Types...> >
// {
-// public:
// typedef Ti type;
// };
//
Modified: libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.fail.cpp?rev=357411&r1=357410&r2=357411&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.fail.cpp (original)
+++ libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.fail.cpp Mon Apr 1 09:39:34 2019
@@ -11,9 +11,8 @@
// template <class... Types> class tuple;
// template <size_t I, class... Types>
-// class tuple_element<I, tuple<Types...> >
+// struct tuple_element<I, tuple<Types...> >
// {
-// public:
// typedef Ti type;
// };
Modified: libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp?rev=357411&r1=357410&r2=357411&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp Mon Apr 1 09:39:34 2019
@@ -11,9 +11,8 @@
// template <class... Types> class tuple;
// template <size_t I, class... Types>
-// class tuple_element<I, tuple<Types...> >
+// struct tuple_element<I, tuple<Types...> >
// {
-// public:
// typedef Ti type;
// };
Modified: libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp?rev=357411&r1=357410&r2=357411&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp Mon Apr 1 09:39:34 2019
@@ -116,8 +116,7 @@ template <size_t N>
int get(Test const&) { static_assert(N == 0, ""); return -1; }
template <>
-class std::tuple_element<0, Test> {
-public:
+struct std::tuple_element<0, Test> {
typedef int type;
};
More information about the libcxx-commits
mailing list