aboutsummaryrefslogtreecommitdiff
path: root/src/type.h
blob: 2537b70e7c2aaf3edd488efae7c74bd672d3e754 (plain)
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
#ifndef TYPEASVALUE_SRC_TYPE_H_
#define TYPEASVALUE_SRC_TYPE_H_

#include <type_traits>

namespace tav {

template <int Value>
using Int = std::integral_constant<int, Value>;

template <std::size_t Value>
using Size = std::integral_constant<std::size_t, Value>;

template <bool Value>
using Boolean = std::integral_constant<bool, Value>;

template <char Value>
using Char = std::integral_constant<char, Value>;

template <typename Function>
using Eval = typename Function::type;

template <
	typename X,
	typename Y
>
using IsEqual = Eval<std::is_same<X, Y>>;

template <
	typename X,
	typename Y
>
using IsEqualType = IsEqual<
	typename X::value_type,
	typename Y::value_type
>;

template <
	typename X,
	typename Y
>
using IsEqualValue = Boolean<X::value == Y::value>;

template <typename X>
using IsBoolean = IsEqual<typename X::value_type, bool>;

template <typename X>
using IsTrue = IsEqualValue<X, Boolean<true>>;

template <typename X>
using IsSize = IsEqual<typename X::value_type, std::size_t>;

}

#endif  // TYPEASVALUE_SRC_TYPE_H_