I am puzzled as to why it is apparently impossible to compare a subrange of std::string_view with a std::string_view. I mean they ought to be of the same base type and thus comparable to each other?
Can someone explain why this won’t work?
https://godbolt.org/z/3Y6zMaTEv
#include <vector>
#include <string_view>
#include <ranges>
#include <algorithm>
int main() {
std::vector<std::string_view> forbidden{"123", "4fe", "bad"};
std::string_view subject = "foo545jdsf4fesubn55324123434nsomebadstuff";
for (auto&& line : subject | std::ranges::views::split('n')) {
std::ranges::any_of(forbidden, [&line](auto&& bad) {
return std::ranges::find(line, bad) != line.end(); // Complains about something being not callable?!
});
}
return 0;
}