-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.h
More file actions
68 lines (59 loc) · 885 Bytes
/
utils.h
File metadata and controls
68 lines (59 loc) · 885 Bytes
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
#include <iostream>
enum class Type
{
Int,
Float
};
class INT
{
public:
INT()
{
std::cout << "INT" << std::endl;
};
void print() const
{
}
};
class FLOAT
{
public:
FLOAT()
{
std::cout << "FLOAT" << std::endl;
};
void print() const
{
}
};
template <typename T>
void func1(T t)
{
std::cout << "func1" << std::endl;
}
void func2()
{
std::cout << "func2" << std::endl;
}
template <typename T,
auto t,
typename T1 = std::conditional_t<t == Type::Int,INT,FLOAT>>
void func()
{
T1 a;
if constexpr (std::is_same_v<decltype(t),Type>)
{
if constexpr (t == Type::Int)
{
func1(t);
}
else if constexpr (t == Type::Float)
{
func2();
}
}
else
{
static_assert(true,"fail");
}
}