From cd43985ebae5cfda6234a356ce724491bef48e95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C5=BEenan=20Zuki=C4=87?= Date: Fri, 10 Sep 2021 11:36:09 -0400 Subject: [PATCH] ENH: replace itkStaticAssert by STL's static_assert This is a follow-up to d3e151f09d04830c8ef6ac2f2b104d247ffb99f3. --- .../test/itkMetaProgrammingLibraryTest.cxx | 93 +++++++++---------- 1 file changed, 44 insertions(+), 49 deletions(-) diff --git a/Modules/Core/Common/test/itkMetaProgrammingLibraryTest.cxx b/Modules/Core/Common/test/itkMetaProgrammingLibraryTest.cxx index b287e681bf0..c7aff1f450b 100644 --- a/Modules/Core/Common/test/itkMetaProgrammingLibraryTest.cxx +++ b/Modules/Core/Common/test/itkMetaProgrammingLibraryTest.cxx @@ -19,7 +19,6 @@ #include #include "itkMetaProgrammingLibrary.h" -#include "itkStaticAssert.h" int @@ -27,69 +26,65 @@ itkMetaProgrammingLibraryTest(int, char *[]) { using namespace itk::mpl; -#if !defined(ITK_LEGACY_REMOVE) - // Or between constants - itkStaticAssert((OrC::Value == true), "Unit test failed"); - itkStaticAssert((OrC::Value == true), "Unit test failed"); - itkStaticAssert((OrC::Value == true), "Unit test failed"); - itkStaticAssert((OrC::Value == true), "Unit test failed"); - itkStaticAssert((OrC::Value == true), "Unit test failed"); - itkStaticAssert((OrC::Value == true), "Unit test failed"); - itkStaticAssert((OrC::Value == false), "Unit test failed"); - - itkStaticAssert((OrC::Value == true), "Unit test failed"); - itkStaticAssert((OrC::Value == true), "Unit test failed"); - itkStaticAssert((OrC::Value == true), "Unit test failed"); - itkStaticAssert((OrC::Value == false), "Unit test failed"); + static_assert((OrC::Value == true), "Unit test failed"); + static_assert((OrC::Value == true), "Unit test failed"); + static_assert((OrC::Value == true), "Unit test failed"); + static_assert((OrC::Value == true), "Unit test failed"); + static_assert((OrC::Value == true), "Unit test failed"); + static_assert((OrC::Value == true), "Unit test failed"); + static_assert((OrC::Value == false), "Unit test failed"); + + static_assert((OrC::Value == true), "Unit test failed"); + static_assert((OrC::Value == true), "Unit test failed"); + static_assert((OrC::Value == true), "Unit test failed"); + static_assert((OrC::Value == false), "Unit test failed"); // Or between types - itkStaticAssert((std::is_same::Type, TrueType>::value), "Unit test failed"); - itkStaticAssert((std::is_same::Type, TrueType>::value), "Unit test failed"); - itkStaticAssert((std::is_same::Type, TrueType>::value), "Unit test failed"); - itkStaticAssert((std::is_same::Type, TrueType>::value), "Unit test failed"); - itkStaticAssert((std::is_same::Type, TrueType>::value), "Unit test failed"); - itkStaticAssert((std::is_same::Type, TrueType>::value), "Unit test failed"); - itkStaticAssert((std::is_same::Type, FalseType>::value), "Unit test failed"); - - itkStaticAssert((std::is_same::Type, TrueType>::value), "Unit test failed"); - itkStaticAssert((std::is_same::Type, TrueType>::value), "Unit test failed"); - itkStaticAssert((std::is_same::Type, TrueType>::value), "Unit test failed"); - itkStaticAssert((std::is_same::Type, FalseType>::value), "Unit test failed"); + static_assert((std::is_same::Type, TrueType>::value), "Unit test failed"); + static_assert((std::is_same::Type, TrueType>::value), "Unit test failed"); + static_assert((std::is_same::Type, TrueType>::value), "Unit test failed"); + static_assert((std::is_same::Type, TrueType>::value), "Unit test failed"); + static_assert((std::is_same::Type, TrueType>::value), "Unit test failed"); + static_assert((std::is_same::Type, TrueType>::value), "Unit test failed"); + static_assert((std::is_same::Type, FalseType>::value), "Unit test failed"); + + static_assert((std::is_same::Type, TrueType>::value), "Unit test failed"); + static_assert((std::is_same::Type, TrueType>::value), "Unit test failed"); + static_assert((std::is_same::Type, TrueType>::value), "Unit test failed"); + static_assert((std::is_same::Type, FalseType>::value), "Unit test failed"); // And between constants - itkStaticAssert((AndC::Value == true), "Unit test failed"); - itkStaticAssert((AndC::Value == false), "Unit test failed"); - itkStaticAssert((AndC::Value == false), "Unit test failed"); - itkStaticAssert((AndC::Value == false), "Unit test failed"); + static_assert((AndC::Value == true), "Unit test failed"); + static_assert((AndC::Value == false), "Unit test failed"); + static_assert((AndC::Value == false), "Unit test failed"); + static_assert((AndC::Value == false), "Unit test failed"); // And between types - itkStaticAssert((std::is_same::Type, TrueType>::value), "Unit test failed"); - itkStaticAssert((std::is_same::Type, FalseType>::value), "Unit test failed"); - itkStaticAssert((std::is_same::Type, FalseType>::value), "Unit test failed"); - itkStaticAssert((std::is_same::Type, FalseType>::value), "Unit test failed"); + static_assert((std::is_same::Type, TrueType>::value), "Unit test failed"); + static_assert((std::is_same::Type, FalseType>::value), "Unit test failed"); + static_assert((std::is_same::Type, FalseType>::value), "Unit test failed"); + static_assert((std::is_same::Type, FalseType>::value), "Unit test failed"); // Xor between constants - itkStaticAssert((XorC::Value == false), "Unit test failed"); - itkStaticAssert((XorC::Value == true), "Unit test failed"); - itkStaticAssert((XorC::Value == true), "Unit test failed"); - itkStaticAssert((XorC::Value == false), "Unit test failed"); + static_assert((XorC::Value == false), "Unit test failed"); + static_assert((XorC::Value == true), "Unit test failed"); + static_assert((XorC::Value == true), "Unit test failed"); + static_assert((XorC::Value == false), "Unit test failed"); // Xor between types - itkStaticAssert((std::is_same::Type, FalseType>::value), "Unit test failed"); - itkStaticAssert((std::is_same::Type, TrueType>::value), "Unit test failed"); - itkStaticAssert((std::is_same::Type, TrueType>::value), "Unit test failed"); - itkStaticAssert((std::is_same::Type, FalseType>::value), "Unit test failed"); + static_assert((std::is_same::Type, FalseType>::value), "Unit test failed"); + static_assert((std::is_same::Type, TrueType>::value), "Unit test failed"); + static_assert((std::is_same::Type, TrueType>::value), "Unit test failed"); + static_assert((std::is_same::Type, FalseType>::value), "Unit test failed"); // Not between constants - itkStaticAssert((NotC::Value == false), "Unit test failed"); - itkStaticAssert((NotC::Value == true), "Unit test failed"); + static_assert((NotC::Value == false), "Unit test failed"); + static_assert((NotC::Value == true), "Unit test failed"); // Not between types - itkStaticAssert((std::is_same::Type, FalseType>::value), "Unit test failed"); - itkStaticAssert((std::is_same::Type, TrueType>::value), "Unit test failed"); - -#endif + static_assert((std::is_same::Type, FalseType>::value), "Unit test failed"); + static_assert((std::is_same::Type, TrueType>::value), "Unit test failed"); return EXIT_SUCCESS; }