- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
constexpr std::size_t find(string_view str, char c) noexcept {
#if defined(__clang__) && __clang_major__ < 9 && defined(__GLIBCXX__) || defined(_MSC_VER) && _MSC_VER < 1920 && !defined(__clang__)
// https://stackoverflow.com/questions/56484834/constexpr-stdstring-viewfind-last-of-doesnt-work-on-clang-8-with-libstdc
// https://developercommunity.visualstudio.com/content/problem/360432/vs20178-regression-c-failed-in-test.html
constexpr bool workaround = true;
#else
constexpr bool workaround = false;
#endif
if constexpr (workaround) {
for (std::size_t i = 0; i < str.size(); ++i) {
if (str[i] == c) {
return i;
}
}
return string_view::npos;
} else {
return str.find_first_of(c);
}
}
Комментарии (0) RSS
Добавить комментарий