xref: /llvm-project/libcxx/include/__type_traits/type_list.h (revision 0429bfea49615882e89ee2350ffde777ce77fb95)
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___TYPE_TRAITS_TYPE_LIST_H
10 #define _LIBCPP___TYPE_TRAITS_TYPE_LIST_H
11 
12 #include <__config>
13 #include <__cstddef/size_t.h>
14 
15 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16 #  pragma GCC system_header
17 #endif
18 
19 _LIBCPP_BEGIN_NAMESPACE_STD
20 
21 template <class... _Types>
22 struct __type_list {};
23 
24 template <class>
25 struct __type_list_head;
26 
27 template <class _Head, class... _Tail>
28 struct __type_list_head<__type_list<_Head, _Tail...> > {
29   using type _LIBCPP_NODEBUG = _Head;
30 };
31 
32 template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename __type_list_head<_TypeList>::type)>
33 struct __find_first;
34 
35 template <class _Head, class... _Tail, size_t _Size>
36 struct __find_first<__type_list<_Head, _Tail...>, _Size, true> {
37   using type _LIBCPP_NODEBUG = _Head;
38 };
39 
40 template <class _Head, class... _Tail, size_t _Size>
41 struct __find_first<__type_list<_Head, _Tail...>, _Size, false> {
42   using type _LIBCPP_NODEBUG = typename __find_first<__type_list<_Tail...>, _Size>::type;
43 };
44 
45 _LIBCPP_END_NAMESPACE_STD
46 
47 #endif // _LIBCPP___TYPE_TRAITS_TYPE_LIST_H
48