1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef TEST_SUPPORT_TYPE_ALGORITHMS_H
#define TEST_SUPPORT_TYPE_ALGORITHMS_H
#include <type_traits>
#include "test_macros.h"
namespace types {
template <class... Types>
struct type_list {};
// concatenates N type_lists to one (for N >= 1)
template <class...>
struct concatenate;
template <class... Types>
using concatenate_t = typename concatenate<Types...>::type;
// for_each takes a type_list calls f with each element as the first template argument
template <class... Types, class Functor>
TEST_CONSTEXPR_CXX14 void for_each(type_list<Types...>, Functor f);
// impl
template <class... Types>
struct concatenate<type_list<Types...> > {
using type = type_list<Types...>;
};
template <class... Types1, class... Types2>
struct concatenate<type_list<Types1...>, type_list<Types2...> > {
using type = type_list<Types1..., Types2...>;
};
template <class... Types1, class... Types2, class... Rest>
struct concatenate<type_list<Types1...>, type_list<Types2...>, Rest...> {
using type = concatenate_t<type_list<Types1..., Types2...>, Rest...>;
};
template <class... Types>
TEST_CONSTEXPR_CXX14 void swallow(Types...) {}
template <class... Types, class Functor>
TEST_CONSTEXPR_CXX14 void for_each(type_list<Types...>, Functor f) {
swallow((f.template operator()<Types>(), 0)...);
}
template <template <class...> class T, class... Args>
struct partial_instantiation {
template <class Other>
using apply = T<Args..., Other>;
};
// type categories defined in [basic.fundamental] plus extensions (without CV-qualifiers)
using character_types =
type_list<char
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
,
wchar_t
#endif
#ifndef TEST_HAS_NO_CHAR8_T
,
char8_t
#endif
#if TEST_STD_VER >= 11
,
char16_t,
char32_t
#endif
>;
using signed_integer_types =
type_list<signed char,
short,
int,
long,
long long
#ifndef TEST_HAS_NO_INT128
,
__int128_t
#endif
>;
using unsigned_integer_types =
type_list<unsigned char,
unsigned short,
unsigned int,
unsigned long,
unsigned long long
#ifndef TEST_HAS_NO_INT128
,
__uint128_t
#endif
>;
using integral_types = concatenate_t<character_types, signed_integer_types, unsigned_integer_types, type_list<bool> >;
using floating_point_types = type_list<float, double, long double>;
using arithmetic_types = concatenate_t<integral_types, floating_point_types>;
template <class T>
using cv_qualified_versions = type_list<T, const T, volatile T, const volatile T>;
template <class T>
struct type_list_as_pointers;
template <class... Types>
struct type_list_as_pointers<type_list<Types...> > {
using type = type_list<Types*...>;
};
template <class T>
using as_pointers = typename type_list_as_pointers<T>::type;
} // namespace types
#endif // TEST_SUPPORT_TYPE_ALGORITHMS_H
|