diff --git a/src/catch2/benchmark/catch_benchmark.hpp b/src/catch2/benchmark/catch_benchmark.hpp index d0f88cfc..eb688e7d 100644 --- a/src/catch2/benchmark/catch_benchmark.hpp +++ b/src/catch2/benchmark/catch_benchmark.hpp @@ -97,7 +97,7 @@ namespace Catch { } // sets lambda to be used in fun *and* executes benchmark! - template ::value, int> = 0> + template , int> = 0> Benchmark & operator=(Fun func) { auto const* cfg = getCurrentContext().getConfig(); if (!cfg->skipBenchmarks()) { diff --git a/src/catch2/benchmark/detail/catch_benchmark_function.hpp b/src/catch2/benchmark/detail/catch_benchmark_function.hpp index a03cb112..90b07b76 100644 --- a/src/catch2/benchmark/detail/catch_benchmark_function.hpp +++ b/src/catch2/benchmark/detail/catch_benchmark_function.hpp @@ -21,8 +21,7 @@ namespace Catch { namespace Benchmark { namespace Detail { template - struct is_related - : std::is_same, std::decay_t> {}; + static constexpr bool is_related_v = std::is_same, std::decay_t>::value; /// We need to reinvent std::function because every piece of code that might add overhead /// in a measurement context needs to have consistent performance characteristics so that we @@ -63,7 +62,7 @@ namespace Catch { BenchmarkFunction(); template ::value, int> = 0> + std::enable_if_t, int> = 0> BenchmarkFunction(Fun&& fun) : f(new model>(CATCH_FORWARD(fun))) {} diff --git a/src/catch2/catch_tostring.hpp b/src/catch2/catch_tostring.hpp index 5f84196f..70741663 100644 --- a/src/catch2/catch_tostring.hpp +++ b/src/catch2/catch_tostring.hpp @@ -64,18 +64,14 @@ namespace Catch { return rawMemoryToString( &object, sizeof(object) ); } - template - class IsStreamInsertable { - template - static auto test(int) - -> decltype(std::declval() << std::declval(), std::true_type()); + template + static constexpr bool IsStreamInsertable_v = false; - template - static auto test(...)->std::false_type; - - public: - static const bool value = decltype(test(0))::value; - }; + template + static constexpr bool IsStreamInsertable_v< + T, + decltype( void( std::declval() << std::declval() ) )> = + true; template std::string convertUnknownEnumToString( E e ); @@ -120,7 +116,7 @@ namespace Catch { struct StringMaker { template static - std::enable_if_t<::Catch::Detail::IsStreamInsertable::value, std::string> + std::enable_if_t<::Catch::Detail::IsStreamInsertable_v, std::string> convert(const Fake& value) { ReusableStringStream rss; // NB: call using the function-like syntax to avoid ambiguity with @@ -131,7 +127,7 @@ namespace Catch { template static - std::enable_if_t::value, std::string> + std::enable_if_t, std::string> convert( const Fake& value ) { #if !defined(CATCH_CONFIG_FALLBACK_STRINGIFIER) return Detail::convertUnstreamable(value); @@ -523,7 +519,7 @@ namespace Catch { } template - struct StringMaker::value && !::Catch::Detail::IsStreamInsertable::value>> { + struct StringMaker::value && !::Catch::Detail::IsStreamInsertable_v>> { static std::string convert( R const& range ) { return rangeToString( range ); } diff --git a/src/catch2/matchers/catch_matchers_container_properties.hpp b/src/catch2/matchers/catch_matchers_container_properties.hpp index 5f3fc7fb..33795fbe 100644 --- a/src/catch2/matchers/catch_matchers_container_properties.hpp +++ b/src/catch2/matchers/catch_matchers_container_properties.hpp @@ -79,7 +79,7 @@ namespace Catch { //! Creates a matcher that accepts ranges/containers with specific size HasSizeMatcher SizeIs(std::size_t sz); template - std::enable_if_t::value, + std::enable_if_t, SizeMatchesMatcher> SizeIs(Matcher&& m) { return SizeMatchesMatcher{CATCH_FORWARD(m)}; } diff --git a/src/catch2/matchers/catch_matchers_contains.hpp b/src/catch2/matchers/catch_matchers_contains.hpp index 951b42be..940fc225 100644 --- a/src/catch2/matchers/catch_matchers_contains.hpp +++ b/src/catch2/matchers/catch_matchers_contains.hpp @@ -73,14 +73,14 @@ namespace Catch { * Uses `std::equal_to` to do the comparison */ template - std::enable_if_t::value, + std::enable_if_t, ContainsElementMatcher>> Contains(T&& elem) { return { CATCH_FORWARD(elem), std::equal_to<>{} }; } //! Creates a matcher that checks whether a range contains element matching a matcher template - std::enable_if_t::value, + std::enable_if_t, ContainsMatcherMatcher> Contains(Matcher&& matcher) { return { CATCH_FORWARD(matcher) }; } diff --git a/src/catch2/matchers/catch_matchers_templated.hpp b/src/catch2/matchers/catch_matchers_templated.hpp index ba0661ae..fc9fcb2b 100644 --- a/src/catch2/matchers/catch_matchers_templated.hpp +++ b/src/catch2/matchers/catch_matchers_templated.hpp @@ -58,19 +58,19 @@ namespace Matchers { } template - using is_generic_matcher = std::is_base_of< + static constexpr bool is_generic_matcher_v = std::is_base_of< Catch::Matchers::MatcherGenericBase, std::remove_cv_t> - >; + >::value; template - using are_generic_matchers = Catch::Detail::conjunction...>; + static constexpr bool are_generic_matchers_v = Catch::Detail::conjunction>...>::value; template - using is_matcher = std::is_base_of< + static constexpr bool is_matcher_v = std::is_base_of< Catch::Matchers::MatcherUntypedBase, std::remove_cv_t> - >; + >::value; template @@ -143,7 +143,7 @@ namespace Matchers { //! Avoids type nesting for `GenericAllOf && some matcher` case template - friend std::enable_if_t::value, + friend std::enable_if_t, MatchAllOfGeneric> operator && ( MatchAllOfGeneric&& lhs, MatcherRHS const& rhs) { @@ -152,7 +152,7 @@ namespace Matchers { //! Avoids type nesting for `some matcher && GenericAllOf` case template - friend std::enable_if_t::value, + friend std::enable_if_t, MatchAllOfGeneric> operator && ( MatcherLHS const& lhs, MatchAllOfGeneric&& rhs) { @@ -197,7 +197,7 @@ namespace Matchers { //! Avoids type nesting for `GenericAnyOf || some matcher` case template - friend std::enable_if_t::value, + friend std::enable_if_t, MatchAnyOfGeneric> operator || ( MatchAnyOfGeneric&& lhs, MatcherRHS const& rhs) { @@ -206,7 +206,7 @@ namespace Matchers { //! Avoids type nesting for `some matcher || GenericAnyOf` case template - friend std::enable_if_t::value, + friend std::enable_if_t, MatchAnyOfGeneric> operator || ( MatcherLHS const& lhs, MatchAnyOfGeneric&& rhs) { @@ -246,20 +246,20 @@ namespace Matchers { // compose only generic matchers template - std::enable_if_t::value, Detail::MatchAllOfGeneric> + std::enable_if_t, Detail::MatchAllOfGeneric> operator && (MatcherLHS const& lhs, MatcherRHS const& rhs) { return { lhs, rhs }; } template - std::enable_if_t::value, Detail::MatchAnyOfGeneric> + std::enable_if_t, Detail::MatchAnyOfGeneric> operator || (MatcherLHS const& lhs, MatcherRHS const& rhs) { return { lhs, rhs }; } //! Wrap provided generic matcher in generic negator template - std::enable_if_t::value, Detail::MatchNotOfGeneric> + std::enable_if_t, Detail::MatchNotOfGeneric> operator ! (MatcherT const& matcher) { return Detail::MatchNotOfGeneric{matcher}; } @@ -267,25 +267,25 @@ namespace Matchers { // compose mixed generic and non-generic matchers template - std::enable_if_t::value, Detail::MatchAllOfGeneric>> + std::enable_if_t, Detail::MatchAllOfGeneric>> operator && (MatcherLHS const& lhs, MatcherBase const& rhs) { return { lhs, rhs }; } template - std::enable_if_t::value, Detail::MatchAllOfGeneric, MatcherRHS>> + std::enable_if_t, Detail::MatchAllOfGeneric, MatcherRHS>> operator && (MatcherBase const& lhs, MatcherRHS const& rhs) { return { lhs, rhs }; } template - std::enable_if_t::value, Detail::MatchAnyOfGeneric>> + std::enable_if_t, Detail::MatchAnyOfGeneric>> operator || (MatcherLHS const& lhs, MatcherBase const& rhs) { return { lhs, rhs }; } template - std::enable_if_t::value, Detail::MatchAnyOfGeneric, MatcherRHS>> + std::enable_if_t, Detail::MatchAnyOfGeneric, MatcherRHS>> operator || (MatcherBase const& lhs, MatcherRHS const& rhs) { return { lhs, rhs }; }