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
23namespace 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 */
35template <bool VCond, int TIfTrue, int TIfFalse>
37{
38private:
40 typedef
41 typename std::conditional<VCond, std::integral_constant<int, TIfTrue>, std::integral_constant<int, TIfFalse>>::type
43
44public:
45 using Type = typename ConditionalType::type;
46 using ValueType = typename ConditionalType::value_type;
47
48 static const ValueType Value = ConditionalType::value;
49};
50
51
52} // namespace itk::simple
53
54#endif // sitkConditional_h
typename ConditionalType::value_type ValueType
std::conditional< VCond, std::integral_constant< int, TIfTrue >, std::integral_constant< int, TIfFalse > >::type ConditionalType
static const ValueType Value
typename ConditionalType::type Type