@@ -374,19 +374,15 @@ constexpr std::size_t find(string_view str, char_type c) noexcept {
374374}
375375
376376template <typename BinaryPredicate>
377- constexpr bool is_default_predicate () noexcept {
378- return std::is_same_v<std::decay_t <BinaryPredicate>, std::equal_to<string_view::value_type>> ||
379- std::is_same_v<std::decay_t <BinaryPredicate>, std::equal_to<>>;
380- }
377+ inline constexpr bool is_default_predicate_v = std::is_same_v<std::decay_t <BinaryPredicate>, std::equal_to<string_view::value_type>> || std::is_same_v<std::decay_t <BinaryPredicate>, std::equal_to<>>;
378+
381379
382380template <typename BinaryPredicate>
383- constexpr bool is_nothrow_invocable () {
384- return is_default_predicate<BinaryPredicate>() ||
385- std::is_nothrow_invocable_r_v<bool , BinaryPredicate, char_type, char_type>;
386- }
381+ inline constexpr bool is_nothrow_invocable_v = is_default_predicate_v<BinaryPredicate> || std::is_nothrow_invocable_r_v<bool , BinaryPredicate, char_type, char_type>;
382+
387383
388384template <typename BinaryPredicate>
389- constexpr bool cmp_equal (string_view lhs, string_view rhs, [[maybe_unused]] BinaryPredicate&& p) noexcept (is_nothrow_invocable <BinaryPredicate>() ) {
385+ constexpr bool cmp_equal (string_view lhs, string_view rhs, [[maybe_unused]] BinaryPredicate&& p) noexcept (is_nothrow_invocable_v <BinaryPredicate>) {
390386#if defined(_MSC_VER) && _MSC_VER < 1920 && !defined(__clang__)
391387 // https://developercommunity.visualstudio.com/content/problem/360432/vs20178-regression-c-failed-in-test.html
392388 // https://developercommunity.visualstudio.com/content/problem/232218/c-constexpr-string-view.html
@@ -395,7 +391,7 @@ constexpr bool cmp_equal(string_view lhs, string_view rhs, [[maybe_unused]] Bina
395391 constexpr bool workaround = false ;
396392#endif
397393
398- if constexpr (!is_default_predicate <BinaryPredicate>() || workaround) {
394+ if constexpr (!is_default_predicate_v <BinaryPredicate> || workaround) {
399395 if (lhs.size () != rhs.size ()) {
400396 return false ;
401397 }
@@ -1412,12 +1408,12 @@ template <typename E, detail::enum_subtype S = detail::subtype_v<E>>
14121408// Obtains enum value from name.
14131409// Returns optional with enum value.
14141410template <typename E, detail::enum_subtype S = detail::subtype_v<E>, typename BinaryPredicate = std::equal_to<>>
1415- [[nodiscard]] constexpr auto enum_cast (string_view value, [[maybe_unused]] BinaryPredicate p = {}) noexcept (detail::is_nothrow_invocable <BinaryPredicate>() ) -> detail::enable_if_t<E, optional<std::decay_t<E>>, BinaryPredicate> {
1411+ [[nodiscard]] constexpr auto enum_cast (string_view value, [[maybe_unused]] BinaryPredicate p = {}) noexcept (detail::is_nothrow_invocable_v <BinaryPredicate>) -> detail::enable_if_t<E, optional<std::decay_t<E>>, BinaryPredicate> {
14161412 using D = std::decay_t <E>;
14171413 static_assert (detail::is_reflected_v<D, S>, " magic_enum requires enum implementation and valid max and min." );
14181414
14191415#if defined(MAGIC_ENUM_ENABLE_HASH)
1420- if constexpr (detail::is_default_predicate <BinaryPredicate>() ) {
1416+ if constexpr (detail::is_default_predicate_v <BinaryPredicate>) {
14211417 return detail::constexpr_switch<&detail::names_v<D, S>, detail::case_call_t ::index>(
14221418 [](std::size_t i) { return optional<D>{detail::values_v<D, S>[i]}; },
14231419 value,
@@ -1461,7 +1457,7 @@ template <typename E, detail::enum_subtype S = detail::subtype_v<E>>
14611457
14621458// Checks whether enum contains enumerator with such name.
14631459template <typename E, detail::enum_subtype S = detail::subtype_v<E>, typename BinaryPredicate = std::equal_to<>>
1464- [[nodiscard]] constexpr auto enum_contains (string_view value, BinaryPredicate p = {}) noexcept (detail::is_nothrow_invocable <BinaryPredicate>() ) -> detail::enable_if_t<E, bool, BinaryPredicate> {
1460+ [[nodiscard]] constexpr auto enum_contains (string_view value, BinaryPredicate p = {}) noexcept (detail::is_nothrow_invocable_v <BinaryPredicate>) -> detail::enable_if_t<E, bool, BinaryPredicate> {
14651461 using D = std::decay_t <E>;
14661462
14671463 return static_cast <bool >(enum_cast<D, S>(value, std::move (p)));
0 commit comments