ITK  5.4.0
Insight Toolkit
itkIsConvertible.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 * https://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
21#include "itkMacro.h"
22
23#if !defined(ITK_LEGACY_REMOVE)
24
26
27namespace itk
28{
29
32namespace mpl
33{
34namespace Details
35{
36
42struct SfinaeTypes
43{
44 using TOne = char;
45 struct TTwo
46 {
47 char arr__[2];
48 };
49};
50} // namespace Details
51
63template <typename TFrom, typename TTo>
64struct IsConvertible : private Details::SfinaeTypes
65{
66private:
67 static TOne Test(TTo);
68 static TTwo
69 Test(...);
70 static TFrom
71 MakeT();
74public:
75 static constexpr bool Value = sizeof(Test(MakeT())) == sizeof(TOne);
76};
77
78} // end namespace mpl
79
80// itk::IsConvertible has moved to itk::mpl.
81// Expect itk::IsConvertible to be deprecated.
82using mpl::IsConvertible;
83
86} // end namespace itk
87
88#else // ITK_LEGACY_REMOVE
89# error Use C++ 11 std::is_convertible directly
90#endif
91
92#endif // itkIsConvertible_h
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....