MCPcopy Create free account
hub / github.com/Neargye/magic_enum / cmp_equal

Function cmp_equal

include/magic_enum/magic_enum.hpp:392–417  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

390
391template <typename BinaryPredicate>
392constexpr bool cmp_equal(string_view lhs, string_view rhs, [[maybe_unused]] BinaryPredicate&& p) noexcept(is_nothrow_invocable_v<BinaryPredicate>) {
393#if defined(_MSC_VER) && _MSC_VER < 1920 && !defined(__clang__)
394 // https://developercommunity.visualstudio.com/content/problem/360432/vs20178-regression-c-failed-in-test.html
395 // https://developercommunity.visualstudio.com/content/problem/232218/c-constexpr-string-view.html
396 constexpr bool workaround = true;
397#else
398 constexpr bool workaround = false;
399#endif
400
401 if constexpr (!is_default_predicate_v<BinaryPredicate> || workaround) {
402 if (lhs.size() != rhs.size()) {
403 return false;
404 }
405
406 const auto size = lhs.size();
407 for (std::size_t i = 0; i < size; ++i) {
408 if (!p(lhs[i], rhs[i])) {
409 return false;
410 }
411 }
412
413 return true;
414 } else {
415 return lhs == rhs;
416 }
417}
418
419template <typename L, typename R>
420constexpr bool cmp_less(L lhs, R rhs) noexcept {

Callers 2

enum_castFunction · 0.85
enum_flags_castFunction · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected