Home | History | Annotate | Download | only in include
      1 // -*- C++ -*-
      2 //===----------------------------------------------------------------------===//
      3 //
      4 //                     The LLVM Compiler Infrastructure
      5 //
      6 // This file is dual licensed under the MIT and the University of Illinois Open
      7 // Source Licenses. See LICENSE.TXT for details.
      8 //
      9 //===----------------------------------------------------------------------===//
     10 
     11 #ifndef _LIBCPP___TUPLE
     12 #define _LIBCPP___TUPLE
     13 
     14 #include <__config>
     15 #include <cstddef>
     16 #include <type_traits>
     17 
     18 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
     19 #pragma GCC system_header
     20 #endif
     21 
     22 
     23 _LIBCPP_BEGIN_NAMESPACE_STD
     24 
     25 template <class _Tp> class _LIBCPP_TEMPLATE_VIS tuple_size;
     26 
     27 #if !defined(_LIBCPP_CXX03_LANG)
     28 template <class _Tp, class...>
     29 using __enable_if_tuple_size_imp = _Tp;
     30 
     31 template <class _Tp>
     32 class _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp<
     33     const _Tp,
     34     typename enable_if<!is_volatile<_Tp>::value>::type,
     35     integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
     36     : public integral_constant<size_t, tuple_size<_Tp>::value> {};
     37 
     38 template <class _Tp>
     39 class _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp<
     40     volatile _Tp,
     41     typename enable_if<!is_const<_Tp>::value>::type,
     42     integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
     43     : public integral_constant<size_t, tuple_size<_Tp>::value> {};
     44 
     45 template <class _Tp>
     46 class _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp<
     47     const volatile _Tp,
     48     integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
     49     : public integral_constant<size_t, tuple_size<_Tp>::value> {};
     50 
     51 #else
     52 template <class _Tp> class _LIBCPP_TEMPLATE_VIS tuple_size<const _Tp> : public tuple_size<_Tp> {};
     53 template <class _Tp> class _LIBCPP_TEMPLATE_VIS tuple_size<volatile _Tp> : public tuple_size<_Tp> {};
     54 template <class _Tp> class _LIBCPP_TEMPLATE_VIS tuple_size<const volatile _Tp> : public tuple_size<_Tp> {};
     55 #endif
     56 
     57 template <size_t _Ip, class _Tp> class _LIBCPP_TEMPLATE_VIS tuple_element;
     58 
     59 template <size_t _Ip, class _Tp>
     60 class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const _Tp>
     61 {
     62 public:
     63     typedef typename add_const<typename tuple_element<_Ip, _Tp>::type>::type type;
     64 };
     65 
     66 template <size_t _Ip, class _Tp>
     67 class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, volatile _Tp>
     68 {
     69 public:
     70     typedef typename add_volatile<typename tuple_element<_Ip, _Tp>::type>::type type;
     71 };
     72 
     73 template <size_t _Ip, class _Tp>
     74 class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const volatile _Tp>
     75 {
     76 public:
     77     typedef typename add_cv<typename tuple_element<_Ip, _Tp>::type>::type type;
     78 };
     79 
     80 template <class _Tp> struct __tuple_like : false_type {};
     81 
     82 template <class _Tp> struct __tuple_like<const _Tp> : public __tuple_like<_Tp> {};
     83 template <class _Tp> struct __tuple_like<volatile _Tp> : public __tuple_like<_Tp> {};
     84 template <class _Tp> struct __tuple_like<const volatile _Tp> : public __tuple_like<_Tp> {};
     85 
     86 // tuple specializations
     87 
     88 #if !defined(_LIBCPP_HAS_NO_VARIADICS)
     89 
     90 template <size_t...> struct __tuple_indices {};
     91 
     92 template <class _IdxType, _IdxType... _Values>
     93 struct __integer_sequence {
     94   template <template <class _OIdxType, _OIdxType...> class _ToIndexSeq, class _ToIndexType>
     95   using __convert = _ToIndexSeq<_ToIndexType, _Values...>;
     96 
     97   template <size_t _Sp>
     98   using __to_tuple_indices = __tuple_indices<(_Values + _Sp)...>;
     99 };
    100 
    101 #if !__has_builtin(__make_integer_seq) || defined(_LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE)
    102 namespace __detail {
    103 
    104 template<typename _Tp, size_t ..._Extra> struct __repeat;
    105 template<typename _Tp, _Tp ..._Np, size_t ..._Extra> struct __repeat<__integer_sequence<_Tp, _Np...>, _Extra...> {
    106   typedef __integer_sequence<_Tp,
    107                            _Np...,
    108                            sizeof...(_Np) + _Np...,
    109                            2 * sizeof...(_Np) + _Np...,
    110                            3 * sizeof...(_Np) + _Np...,
    111                            4 * sizeof...(_Np) + _Np...,
    112                            5 * sizeof...(_Np) + _Np...,
    113                            6 * sizeof...(_Np) + _Np...,
    114                            7 * sizeof...(_Np) + _Np...,
    115                            _Extra...> type;
    116 };
    117 
    118 template<size_t _Np> struct __parity;
    119 template<size_t _Np> struct __make : __parity<_Np % 8>::template __pmake<_Np> {};
    120 
    121 template<> struct __make<0> { typedef __integer_sequence<size_t> type; };
    122 template<> struct __make<1> { typedef __integer_sequence<size_t, 0> type; };
    123 template<> struct __make<2> { typedef __integer_sequence<size_t, 0, 1> type; };
    124 template<> struct __make<3> { typedef __integer_sequence<size_t, 0, 1, 2> type; };
    125 template<> struct __make<4> { typedef __integer_sequence<size_t, 0, 1, 2, 3> type; };
    126 template<> struct __make<5> { typedef __integer_sequence<size_t, 0, 1, 2, 3, 4> type; };
    127 template<> struct __make<6> { typedef __integer_sequence<size_t, 0, 1, 2, 3, 4, 5> type; };
    128 template<> struct __make<7> { typedef __integer_sequence<size_t, 0, 1, 2, 3, 4, 5, 6> type; };
    129 
    130 template<> struct __parity<0> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type> {}; };
    131 template<> struct __parity<1> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 1> {}; };
    132 template<> struct __parity<2> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 2, _Np - 1> {}; };
    133 template<> struct __parity<3> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 3, _Np - 2, _Np - 1> {}; };
    134 template<> struct __parity<4> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
    135 template<> struct __parity<5> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
    136 template<> struct __parity<6> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 6, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
    137 template<> struct __parity<7> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 7, _Np - 6, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
    138 
    139 } // namespace detail
    140 
    141 #endif  // !__has_builtin(__make_integer_seq) || defined(_LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE)
    142 
    143 #if __has_builtin(__make_integer_seq)
    144 template <size_t _Ep, size_t _Sp>
    145 using __make_indices_imp =
    146     typename __make_integer_seq<__integer_sequence, size_t, _Ep - _Sp>::template
    147     __to_tuple_indices<_Sp>;
    148 #else
    149 template <size_t _Ep, size_t _Sp>
    150 using __make_indices_imp =
    151     typename __detail::__make<_Ep - _Sp>::type::template __to_tuple_indices<_Sp>;
    152 
    153 #endif
    154 
    155 template <size_t _Ep, size_t _Sp = 0>
    156 struct __make_tuple_indices
    157 {
    158     static_assert(_Sp <= _Ep, "__make_tuple_indices input error");
    159     typedef __make_indices_imp<_Ep, _Sp> type;
    160 };
    161 
    162 
    163 template <class ..._Tp> class _LIBCPP_TEMPLATE_VIS tuple;
    164 
    165 template <class... _Tp> struct __tuple_like<tuple<_Tp...> > : true_type {};
    166 
    167 template <class ..._Tp>
    168 class _LIBCPP_TEMPLATE_VIS tuple_size<tuple<_Tp...> >
    169     : public integral_constant<size_t, sizeof...(_Tp)>
    170 {
    171 };
    172 
    173 template <size_t _Ip, class ..._Tp>
    174 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
    175 typename tuple_element<_Ip, tuple<_Tp...> >::type&
    176 get(tuple<_Tp...>&) _NOEXCEPT;
    177 
    178 template <size_t _Ip, class ..._Tp>
    179 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
    180 const typename tuple_element<_Ip, tuple<_Tp...> >::type&
    181 get(const tuple<_Tp...>&) _NOEXCEPT;
    182 
    183 template <size_t _Ip, class ..._Tp>
    184 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
    185 typename tuple_element<_Ip, tuple<_Tp...> >::type&&
    186 get(tuple<_Tp...>&&) _NOEXCEPT;
    187 
    188 template <size_t _Ip, class ..._Tp>
    189 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
    190 const typename tuple_element<_Ip, tuple<_Tp...> >::type&&
    191 get(const tuple<_Tp...>&&) _NOEXCEPT;
    192 #endif
    193 
    194 // pair specializations
    195 
    196 template <class _T1, class _T2> struct __tuple_like<pair<_T1, _T2> > : true_type {};
    197 
    198 template <size_t _Ip, class _T1, class _T2>
    199 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
    200 typename tuple_element<_Ip, pair<_T1, _T2> >::type&
    201 get(pair<_T1, _T2>&) _NOEXCEPT;
    202 
    203 template <size_t _Ip, class _T1, class _T2>
    204 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
    205 const typename tuple_element<_Ip, pair<_T1, _T2> >::type&
    206 get(const pair<_T1, _T2>&) _NOEXCEPT;
    207 
    208 #if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
    209 template <size_t _Ip, class _T1, class _T2>
    210 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
    211 typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
    212 get(pair<_T1, _T2>&&) _NOEXCEPT;
    213 
    214 template <size_t _Ip, class _T1, class _T2>
    215 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
    216 const typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
    217 get(const pair<_T1, _T2>&&) _NOEXCEPT;
    218 #endif
    219 
    220 // array specializations
    221 
    222 template <class _Tp, size_t _Size> struct _LIBCPP_TEMPLATE_VIS array;
    223 
    224 template <class _Tp, size_t _Size> struct __tuple_like<array<_Tp, _Size> > : true_type {};
    225 
    226 template <size_t _Ip, class _Tp, size_t _Size>
    227 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
    228 _Tp&
    229 get(array<_Tp, _Size>&) _NOEXCEPT;
    230 
    231 template <size_t _Ip, class _Tp, size_t _Size>
    232 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
    233 const _Tp&
    234 get(const array<_Tp, _Size>&) _NOEXCEPT;
    235 
    236 #if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
    237 template <size_t _Ip, class _Tp, size_t _Size>
    238 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
    239 _Tp&&
    240 get(array<_Tp, _Size>&&) _NOEXCEPT;
    241 
    242 template <size_t _Ip, class _Tp, size_t _Size>
    243 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
    244 const _Tp&&
    245 get(const array<_Tp, _Size>&&) _NOEXCEPT;
    246 #endif
    247 
    248 #if !defined(_LIBCPP_HAS_NO_VARIADICS)
    249 
    250 
    251 // __tuple_types
    252 
    253 template <class ..._Tp> struct __tuple_types {};
    254 
    255 #if !__has_builtin(__type_pack_element)
    256 
    257 namespace __indexer_detail {
    258 
    259 template <size_t _Idx, class _Tp>
    260 struct __indexed { using type = _Tp; };
    261 
    262 template <class _Types, class _Indexes> struct __indexer;
    263 
    264 template <class ..._Types, size_t ..._Idx>
    265 struct __indexer<__tuple_types<_Types...>, __tuple_indices<_Idx...>>
    266     : __indexed<_Idx, _Types>...
    267 {};
    268 
    269 template <size_t _Idx, class _Tp>
    270 __indexed<_Idx, _Tp> __at_index(__indexed<_Idx, _Tp> const&);
    271 
    272 } // namespace __indexer_detail
    273 
    274 template <size_t _Idx, class ..._Types>
    275 using __type_pack_element = typename decltype(
    276     __indexer_detail::__at_index<_Idx>(
    277         __indexer_detail::__indexer<
    278             __tuple_types<_Types...>,
    279             typename __make_tuple_indices<sizeof...(_Types)>::type
    280         >{})
    281   )::type;
    282 #endif
    283 
    284 template <size_t _Ip, class ..._Types>
    285 class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, __tuple_types<_Types...>>
    286 {
    287 public:
    288     static_assert(_Ip < sizeof...(_Types), "tuple_element index out of range");
    289     typedef __type_pack_element<_Ip, _Types...> type;
    290 };
    291 
    292 
    293 template <class ..._Tp>
    294 class _LIBCPP_TEMPLATE_VIS tuple_size<__tuple_types<_Tp...> >
    295     : public integral_constant<size_t, sizeof...(_Tp)>
    296 {
    297 };
    298 
    299 template <class... _Tp> struct __tuple_like<__tuple_types<_Tp...> > : true_type {};
    300 
    301 template <bool _ApplyLV, bool _ApplyConst, bool _ApplyVolatile>
    302 struct __apply_cv_mf;
    303 template <>
    304 struct __apply_cv_mf<false, false, false> {
    305   template <class _Tp> using __apply = _Tp;
    306 };
    307 template <>
    308 struct __apply_cv_mf<false, true, false> {
    309   template <class _Tp> using __apply = const _Tp;
    310 };
    311 template <>
    312 struct __apply_cv_mf<false, false, true> {
    313   template <class _Tp> using __apply = volatile _Tp;
    314 };
    315 template <>
    316 struct __apply_cv_mf<false, true, true> {
    317   template <class _Tp> using __apply = const volatile _Tp;
    318 };
    319 template <>
    320 struct __apply_cv_mf<true, false, false> {
    321   template <class _Tp> using __apply = _Tp&;
    322 };
    323 template <>
    324 struct __apply_cv_mf<true, true, false> {
    325   template <class _Tp> using __apply = const _Tp&;
    326 };
    327 template <>
    328 struct __apply_cv_mf<true, false, true> {
    329   template <class _Tp> using __apply = volatile _Tp&;
    330 };
    331 template <>
    332 struct __apply_cv_mf<true, true, true> {
    333   template <class _Tp> using __apply = const volatile _Tp&;
    334 };
    335 template <class _Tp, class _RawTp = typename remove_reference<_Tp>::type>
    336 using __apply_cv_t = __apply_cv_mf<
    337     is_lvalue_reference<_Tp>::value,
    338     is_const<_RawTp>::value,
    339     is_volatile<_RawTp>::value>;
    340 
    341 // __make_tuple_types
    342 
    343 // __make_tuple_types<_Tuple<_Types...>, _Ep, _Sp>::type is a
    344 // __tuple_types<_Types...> using only those _Types in the range [_Sp, _Ep).
    345 // _Sp defaults to 0 and _Ep defaults to tuple_size<_Tuple>.  If _Tuple is a
    346 // lvalue_reference type, then __tuple_types<_Types&...> is the result.
    347 
    348 template <class _TupleTypes, class _TupleIndices>
    349 struct __make_tuple_types_flat;
    350 
    351 template <template <class...> class _Tuple, class ..._Types, size_t ..._Idx>
    352 struct __make_tuple_types_flat<_Tuple<_Types...>, __tuple_indices<_Idx...>> {
    353   // Specialization for pair, tuple, and __tuple_types
    354   template <class _Tp, class _ApplyFn = __apply_cv_t<_Tp>>
    355   using __apply_quals = __tuple_types<
    356       typename _ApplyFn::template __apply<__type_pack_element<_Idx, _Types...>>...
    357     >;
    358 };
    359 
    360 template <class _Vt, size_t _Np, size_t ..._Idx>
    361 struct __make_tuple_types_flat<array<_Vt, _Np>, __tuple_indices<_Idx...>> {
    362   template <size_t>
    363   using __value_type = _Vt;
    364   template <class _Tp, class _ApplyFn = __apply_cv_t<_Tp>>
    365   using __apply_quals = __tuple_types<
    366       typename _ApplyFn::template __apply<__value_type<_Idx>>...
    367     >;
    368 };
    369 
    370 template <class _Tp, size_t _Ep = tuple_size<typename remove_reference<_Tp>::type>::value,
    371           size_t _Sp = 0,
    372           bool _SameSize = (_Ep == tuple_size<typename remove_reference<_Tp>::type>::value)>
    373 struct __make_tuple_types
    374 {
    375     static_assert(_Sp <= _Ep, "__make_tuple_types input error");
    376     using _RawTp = typename remove_cv<typename remove_reference<_Tp>::type>::type;
    377     using _Maker = __make_tuple_types_flat<_RawTp, typename __make_tuple_indices<_Ep, _Sp>::type>;
    378     using type = typename _Maker::template __apply_quals<_Tp>;
    379 };
    380 
    381 template <class ..._Types, size_t _Ep>
    382 struct __make_tuple_types<tuple<_Types...>, _Ep, 0, true> {
    383   typedef __tuple_types<_Types...> type;
    384 };
    385 
    386 template <class ..._Types, size_t _Ep>
    387 struct __make_tuple_types<__tuple_types<_Types...>, _Ep, 0, true> {
    388   typedef __tuple_types<_Types...> type;
    389 };
    390 
    391 template <bool ..._Preds>
    392 struct __all_dummy;
    393 
    394 template <bool ..._Pred>
    395 using __all = is_same<__all_dummy<_Pred...>, __all_dummy<((void)_Pred, true)...>>;
    396 
    397 struct __tuple_sfinae_base {
    398   template <template <class, class...> class _Trait,
    399             class ..._LArgs, class ..._RArgs>
    400   static auto __do_test(__tuple_types<_LArgs...>, __tuple_types<_RArgs...>)
    401     -> __all<typename enable_if<_Trait<_LArgs, _RArgs>::value, bool>::type{true}...>;
    402   template <template <class...> class>
    403   static auto __do_test(...) -> false_type;
    404 
    405   template <class _FromArgs, class _ToArgs>
    406   using __constructible = decltype(__do_test<is_constructible>(_ToArgs{}, _FromArgs{}));
    407   template <class _FromArgs, class _ToArgs>
    408   using __convertible = decltype(__do_test<is_convertible>(_FromArgs{}, _ToArgs{}));
    409   template <class _FromArgs, class _ToArgs>
    410   using __assignable = decltype(__do_test<is_assignable>(_ToArgs{}, _FromArgs{}));
    411 };
    412 
    413 // __tuple_convertible
    414 
    415 template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value,
    416                                 bool = __tuple_like<_Up>::value>
    417 struct __tuple_convertible
    418     : public false_type {};
    419 
    420 template <class _Tp, class _Up>
    421 struct __tuple_convertible<_Tp, _Up, true, true>
    422     : public __tuple_sfinae_base::__convertible<
    423       typename __make_tuple_types<_Tp>::type
    424     , typename __make_tuple_types<_Up>::type
    425     >
    426 {};
    427 
    428 // __tuple_constructible
    429 
    430 template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value,
    431                                 bool = __tuple_like<_Up>::value>
    432 struct __tuple_constructible
    433     : public false_type {};
    434 
    435 template <class _Tp, class _Up>
    436 struct __tuple_constructible<_Tp, _Up, true, true>
    437     : public __tuple_sfinae_base::__constructible<
    438       typename __make_tuple_types<_Tp>::type
    439     , typename __make_tuple_types<_Up>::type
    440     >
    441 {};
    442 
    443 // __tuple_assignable
    444 
    445 template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value,
    446                                 bool = __tuple_like<_Up>::value>
    447 struct __tuple_assignable
    448     : public false_type {};
    449 
    450 template <class _Tp, class _Up>
    451 struct __tuple_assignable<_Tp, _Up, true, true>
    452     : public __tuple_sfinae_base::__assignable<
    453       typename __make_tuple_types<_Tp>::type
    454     , typename __make_tuple_types<_Up&>::type
    455     >
    456 {};
    457 
    458 
    459 template <size_t _Ip, class ..._Tp>
    460 class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, tuple<_Tp...> >
    461 {
    462 public:
    463     typedef typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type;
    464 };
    465 
    466 #if _LIBCPP_STD_VER > 11
    467 template <size_t _Ip, class ..._Tp>
    468 using tuple_element_t = typename tuple_element <_Ip, _Tp...>::type;
    469 #endif
    470 
    471 #endif  // _LIBCPP_HAS_NO_VARIADICS
    472 
    473 #ifndef _LIBCPP_CXX03_LANG
    474 template <bool _IsTuple, class _SizeTrait, size_t _Expected>
    475 struct __tuple_like_with_size_imp : false_type {};
    476 
    477 template <class _SizeTrait, size_t _Expected>
    478 struct __tuple_like_with_size_imp<true, _SizeTrait, _Expected>
    479     : integral_constant<bool, _SizeTrait::value == _Expected> {};
    480 
    481 template <class _Tuple, size_t _ExpectedSize,
    482           class _RawTuple = typename __uncvref<_Tuple>::type>
    483 using __tuple_like_with_size = __tuple_like_with_size_imp<
    484                                    __tuple_like<_RawTuple>::value,
    485                                    tuple_size<_RawTuple>, _ExpectedSize
    486                               >;
    487 
    488 struct _LIBCPP_TYPE_VIS __check_tuple_constructor_fail {
    489     template <class ...>
    490     static constexpr bool __enable_default() { return false; }
    491     template <class ...>
    492     static constexpr bool __enable_explicit() { return false; }
    493     template <class ...>
    494     static constexpr bool __enable_implicit() { return false; }
    495     template <class ...>
    496     static constexpr bool __enable_assign() { return false; }
    497 };
    498 #endif
    499 
    500 #if _LIBCPP_STD_VER > 14
    501 
    502 template <bool _CanCopy, bool _CanMove>
    503 struct __sfinae_ctor_base {};
    504 template <>
    505 struct __sfinae_ctor_base<false, false> {
    506   __sfinae_ctor_base() = default;
    507   __sfinae_ctor_base(__sfinae_ctor_base const&) = delete;
    508   __sfinae_ctor_base(__sfinae_ctor_base &&) = delete;
    509   __sfinae_ctor_base& operator=(__sfinae_ctor_base const&) = default;
    510   __sfinae_ctor_base& operator=(__sfinae_ctor_base&&) = default;
    511 };
    512 template <>
    513 struct __sfinae_ctor_base<true, false> {
    514   __sfinae_ctor_base() = default;
    515   __sfinae_ctor_base(__sfinae_ctor_base const&) = default;
    516   __sfinae_ctor_base(__sfinae_ctor_base &&) = delete;
    517   __sfinae_ctor_base& operator=(__sfinae_ctor_base const&) = default;
    518   __sfinae_ctor_base& operator=(__sfinae_ctor_base&&) = default;
    519 };
    520 template <>
    521 struct __sfinae_ctor_base<false, true> {
    522   __sfinae_ctor_base() = default;
    523   __sfinae_ctor_base(__sfinae_ctor_base const&) = delete;
    524   __sfinae_ctor_base(__sfinae_ctor_base &&) = default;
    525   __sfinae_ctor_base& operator=(__sfinae_ctor_base const&) = default;
    526   __sfinae_ctor_base& operator=(__sfinae_ctor_base&&) = default;
    527 };
    528 
    529 template <bool _CanCopy, bool _CanMove>
    530 struct __sfinae_assign_base {};
    531 template <>
    532 struct __sfinae_assign_base<false, false> {
    533   __sfinae_assign_base() = default;
    534   __sfinae_assign_base(__sfinae_assign_base const&) = default;
    535   __sfinae_assign_base(__sfinae_assign_base &&) = default;
    536   __sfinae_assign_base& operator=(__sfinae_assign_base const&) = delete;
    537   __sfinae_assign_base& operator=(__sfinae_assign_base&&) = delete;
    538 };
    539 template <>
    540 struct __sfinae_assign_base<true, false> {
    541   __sfinae_assign_base() = default;
    542   __sfinae_assign_base(__sfinae_assign_base const&) = default;
    543   __sfinae_assign_base(__sfinae_assign_base &&) = default;
    544   __sfinae_assign_base& operator=(__sfinae_assign_base const&) = default;
    545   __sfinae_assign_base& operator=(__sfinae_assign_base&&) = delete;
    546 };
    547 template <>
    548 struct __sfinae_assign_base<false, true> {
    549   __sfinae_assign_base() = default;
    550   __sfinae_assign_base(__sfinae_assign_base const&) = default;
    551   __sfinae_assign_base(__sfinae_assign_base &&) = default;
    552   __sfinae_assign_base& operator=(__sfinae_assign_base const&) = delete;
    553   __sfinae_assign_base& operator=(__sfinae_assign_base&&) = default;
    554 };
    555 #endif // _LIBCPP_STD_VER > 14
    556 
    557 _LIBCPP_END_NAMESPACE_STD
    558 
    559 #endif  // _LIBCPP___TUPLE
    560