ITK  4.9.0
Insight Segmentation and Registration Toolkit
itkMetaProgrammingLibrary.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkMetaProgrammingLibrary_h
19 #define itkMetaProgrammingLibrary_h
20 
21 #include "itkMacro.h"
22 
23 namespace itk {
24 
26 namespace mpl {
27 
38 struct TrueType
39 {
40  typedef bool ValueType;
41  typedef TrueType Type;
42 
43  itkStaticConstMacro(Value, ValueType, true);
44  operator ValueType() { return Value; }
45 };
46 
51 struct FalseType
52 {
53  typedef bool ValueType;
54  typedef FalseType Type;
55  itkStaticConstMacro(Value, ValueType, false);
56  operator ValueType() { return Value; }
57 };
59 
67 template <bool VP, typename T1, typename T2> struct If;
69 template <typename T1, typename T2> struct If<true , T1, T2>{ typedef T1 Type; };
70 template <typename T1, typename T2> struct If<false, T1, T2>{ typedef T2 Type; };
72 
80 template < bool VF1, bool VF2, bool VF3=false> struct OrC : TrueType { };
82 template <> struct OrC<false, false,false> : FalseType {};
84 
97 template < typename TF1, typename TF2, typename TF3=FalseType> struct Or : OrC<TF1::Value, TF2::Value, TF3::Value>
99 
106 template < bool VF1, bool VF2> struct AndC : FalseType { };
108 template <> struct AndC<true, true> : TrueType {};
110 
122 template < typename TF1, typename TF2> struct And : AndC<TF1::Value, TF2::Value>
124 
131 template < bool VF1, bool VF2> struct XorC : FalseType { };
133 template <> struct XorC<true, false> : TrueType {};
134 template <> struct XorC<false, true> : TrueType {};
136 
148 template < typename TF1, typename TF2> struct Xor : XorC<TF1::Value, TF2::Value>
150 
156 template < bool VF > struct NotC : FalseType { };
158 template <> struct NotC<false> : TrueType {};
159 template <> struct NotC<true> : FalseType {};
161 
172 template < typename TF> struct Not : NotC<TF::Value>
173 { typedef typename NotC<TF::Value>::Type Type; };
174 
175 } // mpl namespace
176 
177 // TrueType and FalseType have moved to itk::mpl.
178 // Expect itk::TrueType and itk::False type to be deprecated.
179 using mpl::TrueType;
180 using mpl::FalseType;
181 
183 } // itk namespace
184 #endif // itkMetaProgrammingLibrary_h
NotC< TF::Value >::Type Type
OrC< TF1::Value, TF2::Value, TF3::Value >::Type Type
AndC< TF1::Value, TF2::Value >::Type Type
XorC< TF1::Value, TF2::Value >::Type Type