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