HTTP
v1.13.1
Loading...
Searching...
No Matches
CheckAtCompileTime.h
Go to the documentation of this file.
1
#ifndef __COMPILE_TIME_CHECK__
2
#define __COMPILE_TIME_CHECK__
3
4
#include <type_traits>
5
#include <string>
6
7
#define CREATE_CHECK_CLASS(checkMethodName, ...) \
8
private: \
9
template<typename T> \
10
static constexpr decltype(std::declval<T>().checkMethodName(__VA_ARGS__), std::true_type()) checked(int); \
11
\
12
template<typename> \
13
static constexpr std::false_type checked(...); \
14
\
15
public: \
16
using type = decltype(checked<dataContainer>(0)); \
17
enum \
18
{ \
19
value = type::value \
20
}; \
21
22
namespace
utility
23
{
24
template
<
typename
dataContainer>
25
class
checkSize
26
{
27
CREATE_CHECK_CLASS
(size);
28
};
29
30
template
<
typename
dataContainer>
31
class
checkResize
32
{
33
CREATE_CHECK_CLASS
(resize, 0);
34
};
35
36
template
<
typename
dataContainer>
37
class
checkData
38
{
39
CREATE_CHECK_CLASS
(data);
40
};
41
42
template
<
typename
dataContainer>
43
class
checkBegin
44
{
45
CREATE_CHECK_CLASS
(begin);
46
};
47
48
template
<
typename
dataContainer>
49
class
checkEnd
50
{
51
CREATE_CHECK_CLASS
(end);
52
};
53
54
template
<
typename
dataContainer>
55
class
checkInitializerListConstructor
56
{
57
protected
:
58
template
<
typename
T>
59
static
constexpr
decltype
(T(std::begin(T()), std::end(T())), std::true_type())
checked
(
int
);
60
61
template
<
typename
>
62
static
constexpr
std::false_type
checked
(...);
63
64
public
:
65
using
type
=
decltype
(
checked<dataContainer>
(0));
66
enum
67
{
68
value
= type::value
69
};
70
};
71
72
template
<
typename
T>
73
class
StringConversion
74
{
75
private
:
76
template
<
typename
U>
77
static
constexpr
decltype
(std::declval<std::string>().append(std::declval<U>()), std::true_type()) check(
int
);
78
79
template
<
typename
>
80
static
constexpr
std::false_type check(...);
81
82
public
:
83
using
type
=
decltype
(check<T>(0));
84
85
enum
86
{
87
value
= type::value
88
};
89
};
90
}
91
92
#endif
CREATE_CHECK_CLASS
#define CREATE_CHECK_CLASS(checkMethodName,...)
Definition
CheckAtCompileTime.h:7
utility::StringConversion
Definition
CheckAtCompileTime.h:74
utility::StringConversion::type
decltype(check< T >(0)) type
Definition
CheckAtCompileTime.h:83
utility::StringConversion::value
@ value
Definition
CheckAtCompileTime.h:87
utility::checkBegin
Definition
CheckAtCompileTime.h:44
utility::checkData
Definition
CheckAtCompileTime.h:38
utility::checkEnd
Definition
CheckAtCompileTime.h:50
utility::checkInitializerListConstructor
Definition
CheckAtCompileTime.h:56
utility::checkInitializerListConstructor::checked
static constexpr decltype(T(std::begin(T()), std::end(T())), std::true_type()) checked(int)
utility::checkInitializerListConstructor::checked
static constexpr std::false_type checked(...)
utility::checkInitializerListConstructor::value
@ value
Definition
CheckAtCompileTime.h:68
utility::checkInitializerListConstructor::type
decltype(checked< dataContainer >(0)) type
Definition
CheckAtCompileTime.h:65
utility::checkResize
Definition
CheckAtCompileTime.h:32
utility::checkSize
Definition
CheckAtCompileTime.h:26
utility
Definition
CheckAtCompileTime.h:23
src
CheckAtCompileTime.h
Generated by
1.12.0