-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtestCompileTime.cpp
40 lines (34 loc) · 1.27 KB
/
testCompileTime.cpp
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
#include <cstddef>
#include <utility>
// The define is here! Define TESTMYVARIANT to test szLogVar::variant. Leave
// undefined to test std::variant
//#define TESTMYVARIANT
#include "../includeForTest.hpp"
template <std::size_t N> struct hasInt {};
template <std::size_t... Idx>
void testCompileTime(std::index_sequence<Idx...>) {
// using expander = bool[];
#ifdef TESTMYVARIANT
typedef szLogVar::variant<hasInt<Idx>...> theVar;
static_cast<void>(theVar{});
//((static_cast<void>(theVar{hasInt<Idx>{}})),...); //tests efficiency of the
//(T&& t) constructor
// static_cast<void>(expander{(
// (static_cast<void>(theVar{hasInt<Idx>{}})),true )...});
//[[maybe_unused]] constexpr bool theBools[]{(
//(static_cast<void>(theVar{hasInt<Idx>{}})),true )...};
#else
typedef std::variant<hasInt<Idx>...> theVar;
static_cast<void>(theVar{});
//[[maybe_unused]] constexpr bool theBools[]{(
//(static_cast<void>(theVar{hasInt<Idx>{}})),true )...};
#endif
}
int main() {
// Was 3000. Feel free to change it
testCompileTime(std::make_index_sequence<1000>{});
/*Takes szLogVar::variant about 30 seconds to construct
szLogVar::variant<hasInt<0>...hasInt<2999>> Implementation defined, but this
usually exceeds the default max template instantiation limit on other variants
*/
}