Warning: This file is not a C or C++ file. It does not have highlighting.
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 <__cstddef/size_t.h> |
14 | #include <__fwd/array.h> |
15 | #include <__fwd/tuple.h> |
16 | #include <__tuple/tuple_element.h> |
17 | #include <__tuple/tuple_indices.h> |
18 | #include <__tuple/tuple_size.h> |
19 | #include <__tuple/tuple_types.h> |
20 | #include <__type_traits/copy_cvref.h> |
21 | #include <__type_traits/remove_cvref.h> |
22 | #include <__type_traits/remove_reference.h> |
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> |
44 | using __apply_quals _LIBCPP_NODEBUG = __tuple_types<__copy_cvref_t<_Tp, __type_pack_element<_Idx, _Types...>>...>; |
45 | }; |
46 | |
47 | template <class _Vt, size_t _Np, size_t... _Idx> |
48 | struct __make_tuple_types_flat<array<_Vt, _Np>, __tuple_indices<_Idx...>> { |
49 | template <size_t> |
50 | using __value_type _LIBCPP_NODEBUG = _Vt; |
51 | template <class _Tp> |
52 | using __apply_quals _LIBCPP_NODEBUG = __tuple_types<__copy_cvref_t<_Tp, __value_type<_Idx>>...>; |
53 | }; |
54 | |
55 | template <class _Tp, |
56 | size_t _Ep = tuple_size<__libcpp_remove_reference_t<_Tp> >::value, |
57 | size_t _Sp = 0, |
58 | bool _SameSize = (_Ep == tuple_size<__libcpp_remove_reference_t<_Tp> >::value)> |
59 | struct __make_tuple_types { |
60 | static_assert(_Sp <= _Ep, "__make_tuple_types input error"); |
61 | using _RawTp _LIBCPP_NODEBUG = __remove_cvref_t<_Tp>; |
62 | using _Maker _LIBCPP_NODEBUG = __make_tuple_types_flat<_RawTp, typename __make_tuple_indices<_Ep, _Sp>::type>; |
63 | using type _LIBCPP_NODEBUG = typename _Maker::template __apply_quals<_Tp>; |
64 | }; |
65 | |
66 | template <class... _Types, size_t _Ep> |
67 | struct __make_tuple_types<tuple<_Types...>, _Ep, 0, true> { |
68 | using type _LIBCPP_NODEBUG = __tuple_types<_Types...>; |
69 | }; |
70 | |
71 | template <class... _Types, size_t _Ep> |
72 | struct __make_tuple_types<__tuple_types<_Types...>, _Ep, 0, true> { |
73 | using type _LIBCPP_NODEBUG = __tuple_types<_Types...>; |
74 | }; |
75 | |
76 | _LIBCPP_END_NAMESPACE_STD |
77 | |
78 | #endif // _LIBCPP_CXX03_LANG |
79 | |
80 | #endif // _LIBCPP___TUPLE_MAKE_TUPLE_TYPES_H |
81 |
Warning: This file is not a C or C++ file. It does not have highlighting.