1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef _LIBCPP___TUPLE_MAKE_TUPLE_TYPES_H 10 #define _LIBCPP___TUPLE_MAKE_TUPLE_TYPES_H 11 12 #include <__config> 13 #include <__fwd/array.h> 14 #include <__fwd/tuple.h> 15 #include <__tuple_dir/apply_cv.h> 16 #include <__tuple_dir/tuple_element.h> 17 #include <__tuple_dir/tuple_indices.h> 18 #include <__tuple_dir/tuple_size.h> 19 #include <__tuple_dir/tuple_types.h> 20 #include <__type_traits/remove_cv.h> 21 #include <__type_traits/remove_reference.h> 22 #include <cstddef> 23 24 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 25 # pragma GCC system_header 26 #endif 27 28 #ifndef _LIBCPP_CXX03_LANG 29 30 _LIBCPP_BEGIN_NAMESPACE_STD 31 32 // __make_tuple_types<_Tuple<_Types...>, _Ep, _Sp>::type is a 33 // __tuple_types<_Types...> using only those _Types in the range [_Sp, _Ep). 34 // _Sp defaults to 0 and _Ep defaults to tuple_size<_Tuple>. If _Tuple is a 35 // lvalue_reference type, then __tuple_types<_Types&...> is the result. 36 37 template <class _TupleTypes, class _TupleIndices> 38 struct __make_tuple_types_flat; 39 40 template <template <class...> class _Tuple, class ..._Types, size_t ..._Idx> 41 struct __make_tuple_types_flat<_Tuple<_Types...>, __tuple_indices<_Idx...>> { 42 // Specialization for pair, tuple, and __tuple_types 43 template <class _Tp, class _ApplyFn = __apply_cv_t<_Tp>> 44 using __apply_quals _LIBCPP_NODEBUG = __tuple_types< 45 typename _ApplyFn::template __apply<__type_pack_element<_Idx, _Types...>>... 46 >; 47 }; 48 49 template <class _Vt, size_t _Np, size_t ..._Idx> 50 struct __make_tuple_types_flat<array<_Vt, _Np>, __tuple_indices<_Idx...>> { 51 template <size_t> 52 using __value_type = _Vt; 53 template <class _Tp, class _ApplyFn = __apply_cv_t<_Tp>> 54 using __apply_quals = __tuple_types< 55 typename _ApplyFn::template __apply<__value_type<_Idx>>... 56 >; 57 }; 58 59 template <class _Tp, size_t _Ep = tuple_size<__libcpp_remove_reference_t<_Tp> >::value, 60 size_t _Sp = 0, 61 bool _SameSize = (_Ep == tuple_size<__libcpp_remove_reference_t<_Tp> >::value)> 62 struct __make_tuple_types 63 { 64 static_assert(_Sp <= _Ep, "__make_tuple_types input error"); 65 using _RawTp = __remove_cv_t<__libcpp_remove_reference_t<_Tp> >; 66 using _Maker = __make_tuple_types_flat<_RawTp, typename __make_tuple_indices<_Ep, _Sp>::type>; 67 using type = typename _Maker::template __apply_quals<_Tp>; 68 }; 69 70 template <class ..._Types, size_t _Ep> 71 struct __make_tuple_types<tuple<_Types...>, _Ep, 0, true> { 72 typedef _LIBCPP_NODEBUG __tuple_types<_Types...> type; 73 }; 74 75 template <class ..._Types, size_t _Ep> 76 struct __make_tuple_types<__tuple_types<_Types...>, _Ep, 0, true> { 77 typedef _LIBCPP_NODEBUG __tuple_types<_Types...> type; 78 }; 79 80 _LIBCPP_END_NAMESPACE_STD 81 82 #endif // _LIBCPP_CXX03_LANG 83 84 #endif // _LIBCPP___TUPLE_MAKE_TUPLE_TYPES_H 85