CTK
0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
Libs
CommandLineModules
Backend
FunctionPointer
ctkCmdLineModuleBackendFPTypeTraits.h
Go to the documentation of this file.
1
/*=============================================================================
2
3
Library: CTK
4
5
Copyright (c) German Cancer Research Center,
6
Division of Medical and Biological Informatics
7
8
Licensed under the Apache License, Version 2.0 (the "License");
9
you may not use this file except in compliance with the License.
10
You may obtain a copy of the License at
11
12
http://www.apache.org/licenses/LICENSE-2.0
13
14
Unless required by applicable law or agreed to in writing, software
15
distributed under the License is distributed on an "AS IS" BASIS,
16
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
See the License for the specific language governing permissions and
18
limitations under the License.
19
20
=============================================================================*/
21
22
#ifndef CTKCMDLINEMODULEBACKENDFPTYPETRAITS_H
23
#define CTKCMDLINEMODULEBACKENDFPTYPETRAITS_H
24
25
namespace
ctk
{
26
namespace
CmdLineModuleBackendFunctionPointer {
27
28
struct
NullType
{};
29
30
template
<
bool
flag,
typename
T,
typename
U>
31
struct
Select
32
{
33
typedef
T
Result
;
34
};
35
36
template
<
typename
T,
typename
U>
37
struct
Select
<false, T, U>
38
{
39
typedef
U
Result
;
40
};
41
42
template
<
typename
T>
43
class
TypeTraits
44
{
45
private
:
46
47
template
<
class
U>
struct
PointerTraits
48
{
49
enum
{ result =
false
};
50
typedef
NullType
PointeeType
;
51
};
52
template
<
class
U>
struct
PointerTraits<U*>
53
{
54
enum
{ result =
true
};
55
typedef
U
PointeeType
;
56
};
57
template
<
class
U>
struct
ReferenceTraits
58
{
59
enum
{ result =
false
};
60
typedef
NullType
ReferenceType
;
61
};
62
template
<
class
U>
struct
ReferenceTraits<U&>
63
{
64
enum
{ result =
true
};
65
typedef
U
ReferenceType
;
66
};
67
68
template
<
class
U>
struct
UnConst
69
{
70
typedef
U Result;
71
};
72
template
<
class
U>
struct
UnConst<const U>
73
{
74
typedef
U Result;
75
};
76
77
public
:
78
79
typedef
typename
PointerTraits<T>::PointeeType
PointeeType
;
80
typedef
typename
ReferenceTraits<T>::ReferenceType
ReferenceType
;
81
82
enum
{
isPointer
= PointerTraits<T>::result };
83
enum
{
isReference
= ReferenceTraits<T>::result };
84
85
typedef
typename
Select<isPointer, typename UnConst<PointeeType>::Result
,
86
typename
Select<isReference, typename UnConst<ReferenceType>::Result
,
typename
UnConst<T>::Result>::Result >::Result
RawType
;
87
};
88
89
template
<
bool
C,
typename
T =
void
>
90
struct
EnableIf
91
{
92
typedef
T
Type
;
93
};
94
95
template
<
typename
T>
96
struct
EnableIf
<false, T> {};
97
98
template
<
typename
,
typename
>
99
struct
IsSame
100
{
101
static
bool
const
value
=
false
;
102
};
103
104
template
<
typename
A>
105
struct
IsSame
<A, A>
106
{
107
static
bool
const
value
=
true
;
108
};
109
110
template
<
typename
B,
typename
D>
111
struct
IsBaseOf
112
{
113
static
D*
MakeD
();
114
static
char (&
Test
(B*))[1];
115
static
char (&
Test
(...))[2];
116
static
bool
const
value
=
sizeof
Test
(
MakeD
()) == 1 &&
117
!
IsSame<B volatile const, void volatile const>::value
;
118
};
119
120
121
}
122
}
123
124
125
#endif // CTKCMDLINEMODULEBACKENDFPTYPETRAITS_H
ctk::CmdLineModuleBackendFunctionPointer::TypeTraits::ReferenceType
ReferenceTraits< T >::ReferenceType ReferenceType
Definition:
ctkCmdLineModuleBackendFPTypeTraits.h:80
ctk::CmdLineModuleBackendFunctionPointer::IsBaseOf::value
static const bool value
Definition:
ctkCmdLineModuleBackendFPTypeTraits.h:116
ctk::CmdLineModuleBackendFunctionPointer::IsBaseOf::Test
static char(& Test(B *))[1]
ctk::CmdLineModuleBackendFunctionPointer::IsBaseOf::MakeD
static D * MakeD()
ctk::CmdLineModuleBackendFunctionPointer::EnableIf
Definition:
ctkCmdLineModuleBackendFPTypeTraits.h:90
ctk::CmdLineModuleBackendFunctionPointer::EnableIf::Type
T Type
Definition:
ctkCmdLineModuleBackendFPTypeTraits.h:92
ctk::CmdLineModuleBackendFunctionPointer::Select::Result
T Result
Definition:
ctkCmdLineModuleBackendFPTypeTraits.h:33
ctk::CmdLineModuleBackendFunctionPointer::NullType
Definition:
ctkCmdLineModuleBackendFPTypeTraits.h:28
ctk::CmdLineModuleBackendFunctionPointer::Select< false, T, U >::Result
U Result
Definition:
ctkCmdLineModuleBackendFPTypeTraits.h:39
ctk::CmdLineModuleBackendFunctionPointer::IsSame
Definition:
ctkCmdLineModuleBackendFPTypeTraits.h:99
ctk::CmdLineModuleBackendFunctionPointer::IsSame::value
static const bool value
Definition:
ctkCmdLineModuleBackendFPTypeTraits.h:101
ctk::CmdLineModuleBackendFunctionPointer::TypeTraits
Definition:
ctkCmdLineModuleBackendFPTypeTraits.h:43
ctk::CmdLineModuleBackendFunctionPointer::TypeTraits::PointeeType
PointerTraits< T >::PointeeType PointeeType
Definition:
ctkCmdLineModuleBackendFPTypeTraits.h:79
ctk::CmdLineModuleBackendFunctionPointer::TypeTraits::isReference
@ isReference
Definition:
ctkCmdLineModuleBackendFPTypeTraits.h:83
ctk::CmdLineModuleBackendFunctionPointer::IsBaseOf
Definition:
ctkCmdLineModuleBackendFPTypeTraits.h:111
ctk
Definition:
ctkCmdLineModuleBackendFPTypeTraits.h:25
ctk::CmdLineModuleBackendFunctionPointer::TypeTraits::RawType
Select< isPointer, typename UnConst< PointeeType >::Result, typename Select< isReference, typename UnConst< ReferenceType >::Result, typename UnConst< T >::Result >::Result >::Result RawType
Definition:
ctkCmdLineModuleBackendFPTypeTraits.h:86
ctk::CmdLineModuleBackendFunctionPointer::TypeTraits::isPointer
@ isPointer
Definition:
ctkCmdLineModuleBackendFPTypeTraits.h:82
ctk::CmdLineModuleBackendFunctionPointer::Select
Definition:
ctkCmdLineModuleBackendFPTypeTraits.h:31
Generated on Tue Jan 28 2020 00:00:00 for CTK by
1.8.17