OpenMesh
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
GenProg.hh
1
/*===========================================================================*\
2
* *
3
* OpenMesh *
4
* Copyright (C) 2001-2014 by Computer Graphics Group, RWTH Aachen *
5
* www.openmesh.org *
6
* *
7
*---------------------------------------------------------------------------*
8
* This file is part of OpenMesh. *
9
* *
10
* OpenMesh is free software: you can redistribute it and/or modify *
11
* it under the terms of the GNU Lesser General Public License as *
12
* published by the Free Software Foundation, either version 3 of *
13
* the License, or (at your option) any later version with the *
14
* following exceptions: *
15
* *
16
* If other files instantiate templates or use macros *
17
* or inline functions from this file, or you compile this file and *
18
* link it with other files to produce an executable, this file does *
19
* not by itself cause the resulting executable to be covered by the *
20
* GNU Lesser General Public License. This exception does not however *
21
* invalidate any other reasons why the executable file might be *
22
* covered by the GNU Lesser General Public License. *
23
* *
24
* OpenMesh is distributed in the hope that it will be useful, *
25
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
26
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
27
* GNU Lesser General Public License for more details. *
28
* *
29
* You should have received a copy of the GNU LesserGeneral Public *
30
* License along with OpenMesh. If not, *
31
* see <http://www.gnu.org/licenses/>. *
32
* *
33
\*===========================================================================*/
34
35
/*===========================================================================*\
36
* *
37
* $Revision: 990 $ *
38
* $Date: 2014-02-05 10:01:07 +0100 (Mi, 05 Feb 2014) $ *
39
* *
40
\*===========================================================================*/
41
42
43
//=============================================================================
44
//
45
// Utils for generic/generative programming
46
//
47
//=============================================================================
48
49
#ifndef OPENMESH_GENPROG_HH
50
#define OPENMESH_GENPROG_HH
51
52
53
//== INCLUDES =================================================================
54
55
#include <OpenMesh/Core/System/config.h>
56
57
58
//== NAMESPACES ===============================================================
59
60
namespace
OpenMesh {
61
62
namespace
GenProg {
63
#ifndef DOXY_IGNORE_THIS
64
65
//== IMPLEMENTATION ===========================================================
66
67
69
template
<
bool
b>
struct
Bool2Type {
enum
{ my_bool = b }; };
70
72
template
<
int
i>
struct
Int2Type {
enum
{ my_int = i }; };
73
75
typedef
Bool2Type<true> True;
76
78
typedef
Bool2Type<false> False;
79
80
//-----------------------------------------------------------------------------
82
template
<
bool
Expr>
struct
AssertCompile;
83
template
<>
struct
AssertCompile<true> {};
84
85
86
87
//--- Template "if" w/ partial specialization ---------------------------------
88
#if OM_PARTIAL_SPECIALIZATION
89
90
91
template
<
bool
condition,
class
Then,
class
Else>
92
struct
IF {
typedef
Then Result; };
93
99
template
<
class
Then,
class
Else>
100
struct
IF<false, Then, Else> {
typedef
Else Result; };
101
102
103
104
105
106
//--- Template "if" w/o partial specialization --------------------------------
107
#else
108
109
110
struct
SelectThen
111
{
112
template
<
class
Then,
class
Else>
struct
Select {
113
typedef
Then Result;
114
};
115
};
116
117
struct
SelectElse
118
{
119
template
<
class
Then,
class
Else>
struct
Select {
120
typedef
Else Result;
121
};
122
};
123
124
template
<
bool
condition>
struct
ChooseSelector {
125
typedef
SelectThen Result;
126
};
127
128
template
<>
struct
ChooseSelector<false> {
129
typedef
SelectElse Result;
130
};
131
132
139
template
<
bool
condition,
class
Then,
class
Else>
140
class
IF
141
{
142
typedef
typename
ChooseSelector<condition>::Result Selector;
143
public
:
144
typedef
typename
Selector::template Select<Then, Else>::Result Result;
145
};
146
147
#endif
148
149
//=============================================================================
150
#endif
151
}
// namespace GenProg
152
}
// namespace OpenMesh
153
154
#define assert_compile(EXPR) GenProg::AssertCompile<(EXPR)>();
155
156
//=============================================================================
157
#endif // OPENMESH_GENPROG_HH defined
158
//=============================================================================
Project
OpenMesh
, © Computer Graphics Group, RWTH Aachen. Documentation generated using
doxygen
.