While using ranges I got the below error.
It seems that clang 14.0.3 should support ranges which is a c++20 feature.
What would be a reason why it is not working? Is there a flag that I could use? Do you know any clang issues/features related to this?
The error:
error: no member named 'split' in namespace 'std::ranges::views'
auto tokensRanges = blob | std::views::split('.');
Compiler version:
Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: x86_64-apple-darwin22.6.0
The minimal example code:
#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 # or c++2b