ITK
4.4.0
Insight Segmentation and Registration Toolkit
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
ITK
Modules
Core
Common
include
itkEnableIf.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 __itkEnableIf_h
19
#define __itkEnableIf_h
20
21
namespace
itk
22
{
23
24
/* \brief This is an implementation of the enable if idiom.
25
*
26
* Enable if is a common C++ meta-programming technique for example
27
* there is a boost implementation, for more information on its usage
28
* please see:
29
* http://www.boost.org/doc/libs/1_49_0/libs/utility/enable_if.html
30
*
31
* This template enables specialization of a templated function based
32
* on some traits or concepts. It is implemented with SFINAE.
33
*
34
* If the parameter V is true then the Type trait is the second
35
* template parameter, otherwise an implementation does not exist and
36
* with SFIANE another implementation may be choosen.
37
*
38
* Example:
39
* \code
40
*
41
* template< typename T>
42
* typename EnableIfC<
43
* IsSame<T, typename NumericTraits<T>::ValueType>::Value,
44
* T >::Type
45
* GetComponent(const T pix,
46
* unsigned int itkNotUsed( idx ) ) const
47
* {
48
* return pix;
49
* }
50
* \endcode
51
*
52
*/
53
template
<
bool
V,
class
T =
void
>
struct
EnableIfC
{};
55
template
<
class
T>
struct
EnableIfC
<true, T> {
typedef
T Type; };
56
60
/* \brief An implementation of the negation of the enable if idiom.
61
*
62
* \sa EnableIf
63
*/
64
template
<
bool
V,
class
T =
void
>
struct
DisableIfC
{};
66
template
<
class
T>
struct
DisableIfC
<false, T> {
typedef
T Type; };
67
70
}
71
72
#endif // __itkEnableIf_h
73
Generated on Mon May 13 2013 00:48:48 for ITK by
1.8.3.1