106c3fb27SDimitry Andric //===----------------------------------------------------------------------===// 206c3fb27SDimitry Andric // 306c3fb27SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 406c3fb27SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 506c3fb27SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 606c3fb27SDimitry Andric // 706c3fb27SDimitry Andric //===----------------------------------------------------------------------===// 806c3fb27SDimitry Andric 906c3fb27SDimitry Andric #ifndef _LIBCPP___TUPLE_MAKE_TUPLE_TYPES_H 1006c3fb27SDimitry Andric #define _LIBCPP___TUPLE_MAKE_TUPLE_TYPES_H 1106c3fb27SDimitry Andric 1206c3fb27SDimitry Andric #include <__config> 1306c3fb27SDimitry Andric #include <__fwd/array.h> 1406c3fb27SDimitry Andric #include <__fwd/tuple.h> 1506c3fb27SDimitry Andric #include <__tuple/tuple_element.h> 1606c3fb27SDimitry Andric #include <__tuple/tuple_indices.h> 1706c3fb27SDimitry Andric #include <__tuple/tuple_size.h> 1806c3fb27SDimitry Andric #include <__tuple/tuple_types.h> 1906c3fb27SDimitry Andric #include <__type_traits/apply_cv.h> 2006c3fb27SDimitry Andric #include <__type_traits/remove_cv.h> 2106c3fb27SDimitry Andric #include <__type_traits/remove_reference.h> 2206c3fb27SDimitry Andric #include <cstddef> 2306c3fb27SDimitry Andric 2406c3fb27SDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 2506c3fb27SDimitry Andric # pragma GCC system_header 2606c3fb27SDimitry Andric #endif 2706c3fb27SDimitry Andric 2806c3fb27SDimitry Andric #ifndef _LIBCPP_CXX03_LANG 2906c3fb27SDimitry Andric 3006c3fb27SDimitry Andric _LIBCPP_BEGIN_NAMESPACE_STD 3106c3fb27SDimitry Andric 3206c3fb27SDimitry Andric // __make_tuple_types<_Tuple<_Types...>, _Ep, _Sp>::type is a 3306c3fb27SDimitry Andric // __tuple_types<_Types...> using only those _Types in the range [_Sp, _Ep). 3406c3fb27SDimitry Andric // _Sp defaults to 0 and _Ep defaults to tuple_size<_Tuple>. If _Tuple is a 3506c3fb27SDimitry Andric // lvalue_reference type, then __tuple_types<_Types&...> is the result. 3606c3fb27SDimitry Andric 3706c3fb27SDimitry Andric template <class _TupleTypes, class _TupleIndices> 3806c3fb27SDimitry Andric struct __make_tuple_types_flat; 3906c3fb27SDimitry Andric 4006c3fb27SDimitry Andric template <template <class...> class _Tuple, class... _Types, size_t... _Idx> 4106c3fb27SDimitry Andric struct __make_tuple_types_flat<_Tuple<_Types...>, __tuple_indices<_Idx...>> { 4206c3fb27SDimitry Andric // Specialization for pair, tuple, and __tuple_types 4306c3fb27SDimitry Andric template <class _Tp> 4406c3fb27SDimitry Andric using __apply_quals _LIBCPP_NODEBUG = __tuple_types<__apply_cv_t<_Tp, __type_pack_element<_Idx, _Types...>>...>; 4506c3fb27SDimitry Andric }; 4606c3fb27SDimitry Andric 4706c3fb27SDimitry Andric template <class _Vt, size_t _Np, size_t... _Idx> 4806c3fb27SDimitry Andric struct __make_tuple_types_flat<array<_Vt, _Np>, __tuple_indices<_Idx...>> { 4906c3fb27SDimitry Andric template <size_t> 5006c3fb27SDimitry Andric using __value_type = _Vt; 5106c3fb27SDimitry Andric template <class _Tp> 5206c3fb27SDimitry Andric using __apply_quals = __tuple_types<__apply_cv_t<_Tp, __value_type<_Idx>>...>; 5306c3fb27SDimitry Andric }; 5406c3fb27SDimitry Andric 55*cb14a3feSDimitry Andric template <class _Tp, 56*cb14a3feSDimitry Andric size_t _Ep = tuple_size<__libcpp_remove_reference_t<_Tp> >::value, 5706c3fb27SDimitry Andric size_t _Sp = 0, 5806c3fb27SDimitry Andric bool _SameSize = (_Ep == tuple_size<__libcpp_remove_reference_t<_Tp> >::value)> 59*cb14a3feSDimitry Andric struct __make_tuple_types { 6006c3fb27SDimitry Andric static_assert(_Sp <= _Ep, "__make_tuple_types input error"); 6106c3fb27SDimitry Andric using _RawTp = __remove_cv_t<__libcpp_remove_reference_t<_Tp> >; 6206c3fb27SDimitry Andric using _Maker = __make_tuple_types_flat<_RawTp, typename __make_tuple_indices<_Ep, _Sp>::type>; 6306c3fb27SDimitry Andric using type = typename _Maker::template __apply_quals<_Tp>; 6406c3fb27SDimitry Andric }; 6506c3fb27SDimitry Andric 6606c3fb27SDimitry Andric template <class... _Types, size_t _Ep> 6706c3fb27SDimitry Andric struct __make_tuple_types<tuple<_Types...>, _Ep, 0, true> { 6806c3fb27SDimitry Andric typedef _LIBCPP_NODEBUG __tuple_types<_Types...> type; 6906c3fb27SDimitry Andric }; 7006c3fb27SDimitry Andric 7106c3fb27SDimitry Andric template <class... _Types, size_t _Ep> 7206c3fb27SDimitry Andric struct __make_tuple_types<__tuple_types<_Types...>, _Ep, 0, true> { 7306c3fb27SDimitry Andric typedef _LIBCPP_NODEBUG __tuple_types<_Types...> type; 7406c3fb27SDimitry Andric }; 7506c3fb27SDimitry Andric 7606c3fb27SDimitry Andric _LIBCPP_END_NAMESPACE_STD 7706c3fb27SDimitry Andric 7806c3fb27SDimitry Andric #endif // _LIBCPP_CXX03_LANG 7906c3fb27SDimitry Andric 8006c3fb27SDimitry Andric #endif // _LIBCPP___TUPLE_MAKE_TUPLE_TYPES_H 81