mirror of
https://github.com/darlinghq/darling-libcxx.git
synced 2024-11-27 05:40:48 +00:00
[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 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357411 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
eec31ce77c
commit
b857e811b3
@ -53,26 +53,23 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_size<volatile _Tp> : publ
|
||||
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 decltype(
|
||||
#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, 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;
|
||||
};
|
||||
|
||||
|
@ -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<array<_Tp, _Size> >
|
||||
: 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;
|
||||
};
|
||||
|
||||
|
@ -531,11 +531,10 @@ struct _LIBCPP_TEMPLATE_VIS tuple_size<span<_Tp, dynamic_extent>>; // declared b
|
||||
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
|
@ -87,8 +87,8 @@ template <class T> struct tuple_size; // undefined
|
||||
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
|
||||
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
// };
|
||||
//
|
||||
|
@ -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;
|
||||
// };
|
||||
|
||||
|
@ -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;
|
||||
// };
|
||||
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user