SimpleITK  1.2.4
sitkConditional.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 sitkConditional_h
19 #define sitkConditional_h
20 
21 namespace itk
22 {
23 namespace simple
24 {
25 
26 /* \brief An object for selection of a type at compile-time.
27  * *
28  * If VCode is true, then the member Type will be TIfTrue, otherwise
29  * the member typedef Type will be equivalent to TIfFalse.
30  *
31  */
32 template <bool VCond, class TIfTrue, class TIfFalse> struct Conditional { typedef TIfTrue Type; };
34 template<class TIfTrue, class TIfFalse>
35 struct Conditional<false, TIfTrue, TIfFalse> { typedef TIfFalse Type; };
36 
39 /* \brief An object for selecting an integer value at compile-time.
40  *
41  *
42  * If VCode is true, then the member Value will be TIfTrue, otherwise
43  * the member Value will be equivalent to TIfFalse.
44  *
45  * This class also contains a typedef for ValueType, which is an the
46  * selected integral constant as a type.
47  */
48 template <bool VCond, int TIfTrue, int TIfFalse>
50  : public itk::simple::Conditional<VCond,
51  nsstd::integral_constant<int, TIfTrue>,
52  nsstd::integral_constant<int, TIfFalse> >::Type
53 {
54 private:
56 public:
57  typedef typename Self::value_type ValueType;
58  typedef typename Self::type Type;
59 
60  static const ValueType Value = Self::value;
61 };
62 
63 }
64 }
65 
66 #endif // sitkConditional_h
static const ValueType Value