From b19a54c27207ef44e9711c05c7701b202afc8413 Mon Sep 17 00:00:00 2001 From: neargye Date: Wed, 4 Aug 2021 16:30:10 +0300 Subject: [PATCH] clean-up --- include/magic_enum.hpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/include/magic_enum.hpp b/include/magic_enum.hpp index 89b6eb2..8ed6b6d 100644 --- a/include/magic_enum.hpp +++ b/include/magic_enum.hpp @@ -225,6 +225,7 @@ constexpr std::size_t find(string_view str, char c) noexcept { #else constexpr bool workaround = false; #endif + if constexpr (workaround) { for (std::size_t i = 0; i < str.size(); ++i) { if (str[i] == c) { @@ -252,12 +253,9 @@ constexpr bool cmp_equal(string_view lhs, string_view rhs, BinaryPredicate&& p) #else constexpr bool workaround = false; #endif - constexpr bool default_predicate = std::is_same_v, char_equal_to>; + constexpr bool custom_predicate = std::negation_v, char_equal_to>>; - if constexpr (default_predicate && !workaround) { - static_cast(p); - return lhs == rhs; - } else { + if constexpr (custom_predicate || workaround) { if (lhs.size() != rhs.size()) { return false; } @@ -270,6 +268,10 @@ constexpr bool cmp_equal(string_view lhs, string_view rhs, BinaryPredicate&& p) } return true; + } else { + static_cast(p); + + return lhs == rhs; } }