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

Function find

include/magic_enum/magic_enum.hpp:361–381  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

359};
360
361constexpr std::size_t find(string_view str, char_type c) noexcept {
362#if defined(__clang__) && __clang_major__ < 9 && defined(__GLIBCXX__) || defined(_MSC_VER) && _MSC_VER < 1920 && !defined(__clang__)
363// https://stackoverflow.com/questions/56484834/constexpr-stdstring-viewfind-last-of-doesnt-work-on-clang-8-with-libstdc
364// https://developercommunity.visualstudio.com/content/problem/360432/vs20178-regression-c-failed-in-test.html
365 constexpr bool workaround = true;
366#else
367 constexpr bool workaround = false;
368#endif
369
370 if constexpr (workaround) {
371 for (std::size_t i = 0; i < str.size(); ++i) {
372 if (str[i] == c) {
373 return i;
374 }
375 }
376
377 return string_view::npos;
378 } else {
379 return str.find(c);
380 }
381}
382
383template <typename BinaryPredicate>
384inline 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<>>;

Callers 7

closeMethod · 0.85
addMethod · 0.85
isCompleteMethod · 0.85
matchesMethod · 0.85
bitsetMethod · 0.85
findMethod · 0.85
enum_flags_castFunction · 0.85

Calls 2

sizeMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected