ITK  4.9.0
Insight Segmentation and Registration Toolkit
itkIsConvertible.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 itkIsConvertible_h
19 #define itkIsConvertible_h
20 
22 
23 namespace itk
24 {
25 
28 namespace mpl
29 {
30 namespace Details
31 {
32 
38 struct SfinaeTypes
39  {
40  typedef char TOne;
41  typedef struct { char arr__[2]; } TTwo;
42  };
43 } // Details namespace
44 
56 template <typename TFrom, typename TTo>
57 struct IsConvertible
58 : private Details::SfinaeTypes
59 {
60 private:
61  static TOne Test(TTo);
62  static TTwo Test(...);
63  static TFrom MakeT();
64 public:
65  static const bool Value = sizeof(Test(MakeT())) == sizeof(TOne);
66 };
68 
69 } // itk::mpl namespace
70 
71 // itk::IsConvertible has moved to itk::mpl.
72 // Expect itk::IsConvertible to be deprecated.
73 using mpl::IsConvertible;
74