SimpleITK  2.0.0
sitkConditional.h
Go to the documentation of this file.
1 /*=========================================================================
2 *
3 * Copyright NumFOCUS
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 #include <type_traits>
22 
23 namespace itk
24 {
25 namespace simple
26 {
27 
28 /* \brief An object for selecting an integer value at compile-time.
29  *
30  *
31  * If VCode is true, then the member Value will be TIfTrue, otherwise
32  * the member Value will be equivalent to TIfFalse.
33  *
34  * This class also contains a typedef for ValueType, which is an the
35  * selected integral constant as a type.
36  */
37 template <bool VCond, int TIfTrue, int TIfFalse>
39 {
40 private:
42  typedef typename std::conditional<VCond,
43  std::integral_constant<int, TIfTrue>,
44  std::integral_constant<int, TIfFalse> >::type ConditionalType;
45 public:
46  using Type = typename ConditionalType::type;
47  using ValueType = typename ConditionalType::value_type;
48 
49  static const ValueType Value = ConditionalType::value;
50 };
51 
52 
53 }
54 }
55 
56 #endif // sitkConditional_h
itk::simple::ConditionalValue::ValueType
typename ConditionalType::value_type ValueType
Definition: sitkConditional.h:47
itk::simple::ConditionalValue::Type
typename ConditionalType::type Type
Definition: sitkConditional.h:46
itk::simple::ConditionalValue::ConditionalType
std::conditional< VCond, std::integral_constant< int, TIfTrue >, std::integral_constant< int, TIfFalse > >::type ConditionalType
Definition: sitkConditional.h:44
itk::simple::ConditionalValue::Value
static const ValueType Value
Definition: sitkConditional.h:49
itk::simple::ConditionalValue
Definition: sitkConditional.h:38
itk