diff --git a/Documentation/ITK5MigrationGuide.md b/Documentation/ITK5MigrationGuide.md index 4f6f1a01957..f57c1227221 100644 --- a/Documentation/ITK5MigrationGuide.md +++ b/Documentation/ITK5MigrationGuide.md @@ -81,6 +81,7 @@ To modernize your code base, replace: * `MutexLock` with `std::mutex`, and `#include "itkMutexLock.h"` with `#include `. * `mpl::EnableIf::Type` with `std::enable_if_t`, and `#include "itkEnableIf.h"` with `#include `. * `mpl::IsSame::Value` with `std::is_same::value`, and `#include "itkIsSame.h"` with `#include `. + * `mpl::IsBaseOf::Value` with `std::is_base_of::value`, and `#include "itkIsBaseOf.h"` with `#include `. Modern CMake requirement diff --git a/Modules/Core/Common/include/itkIsBaseOf.h b/Modules/Core/Common/include/itkIsBaseOf.h index fddc32988ba..7e012203b82 100644 --- a/Modules/Core/Common/include/itkIsBaseOf.h +++ b/Modules/Core/Common/include/itkIsBaseOf.h @@ -18,9 +18,12 @@ #ifndef itkIsBaseOf_h #define itkIsBaseOf_h -#include "itkIsConvertible.h" #include +#include "itkMacro.h" + +#if !defined(ITK_LEGACY_REMOVE) + namespace itk { /// \cond HIDE_META_PROGRAMMING @@ -39,12 +42,15 @@ namespace mpl template struct IsBaseOf { - static constexpr bool Value = - IsConvertible::Value && !std::is_same::value; + static constexpr bool Value = std::is_base_of::value; }; } // end namespace mpl /// \endcond } // end namespace itk +#else // ITK_LEGACY_REMOVE +# error Use C++ 11 std::is_base_of directly +#endif + #endif // itkIsBaseOf_h diff --git a/Modules/Core/Common/test/CMakeLists.txt b/Modules/Core/Common/test/CMakeLists.txt index 35620bca882..4bc5018b018 100644 --- a/Modules/Core/Common/test/CMakeLists.txt +++ b/Modules/Core/Common/test/CMakeLists.txt @@ -122,7 +122,6 @@ itkMultithreadingTest.cxx itkMetaProgrammingLibraryTest.cxx itkIsConvertible.cxx -itkIsBaseOf.cxx itkPromoteType.cxx itkMetaDataDictionaryTest.cxx itkStdStreamLogOutputTest.cxx diff --git a/Modules/Core/Common/test/itkIsBaseOf.cxx b/Modules/Core/Common/test/itkIsBaseOf.cxx deleted file mode 100644 index 7ea34fa903f..00000000000 --- a/Modules/Core/Common/test/itkIsBaseOf.cxx +++ /dev/null @@ -1,38 +0,0 @@ -/*========================================================================= - * - * Copyright NumFOCUS - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0.txt - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - *=========================================================================*/ - -#include "itkIsBaseOf.h" - -struct Base -{}; -struct Child : Base -{}; - -int -itkIsBaseOf(int, char *[]) -{ - static_assert((itk::mpl::IsConvertible::Value), "Unit test failed"); - static_assert((!itk::mpl::IsConvertible::Value), "Unit test failed"); - - static_assert((itk::mpl::IsBaseOf::Value), "Unit test failed"); - static_assert((!itk::mpl::IsBaseOf::Value), "Unit test failed"); - - static_assert((!itk::mpl::IsBaseOf::Value), "Unit test failed"); - - return EXIT_SUCCESS; -} diff --git a/Utilities/Maintenance/BuildHeaderTest.py b/Utilities/Maintenance/BuildHeaderTest.py index 7cd755db63d..0d41e9703d1 100755 --- a/Utilities/Maintenance/BuildHeaderTest.py +++ b/Utilities/Maintenance/BuildHeaderTest.py @@ -50,6 +50,7 @@ "itkMultiThreader.h", # Compatibility file, it should not be used "itkEnableIf.h", # Compatibility file, it should not be used "itkIsSame.h", # Compatibility file, it should not be used + "itkIsBaseOf.h", # Compatibility file, it should not be used "itkViewImage.h", # Depends on VTK_RENDERING_BACKEND "QuickView.h", # Depends on VTK_RENDERING_BACKEND "itkBSplineDeformableTransformInitializer.h",