I'm getting this error on macOS, with clang, using std=c++20
or std=c++2b
.
error: no member named 'split' in namespace 'std::ranges::views'
auto tokensRanges = blob | std::views::split('.');
Compiler details:
Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: x86_64-apple-darwin22.6.0
The same code works with Visual Studio cl.
What could be a solution to fix this error?
Later edit: std::ranges::views::split
yields the same error.
https://en.cppreference.com/w/cpp/ranges/split_view is a c++20 feature.
A minimal example that reproduces the problem:
#include <iostream>
#include <ranges>
#include <string>
auto main() -> int
{
std::string blob = "test1.test2.test3";
auto tokensRanges = blob | std::ranges::views::split('.');
for (const auto &tokenRange : tokensRanges) {
std::cout<<std::string(tokenRange.begin(), tokenRange.end())<<"\n";
}
return 0;
}
Compilation:
clang++ -o bin -std=c++20 test.cpp