I have Xcode 14 beta, and I tried to compile this join example from cppreference.com.
#include <iostream>
#include <ranges>
#include <string_view>
#include <vector>
int main()
{
using namespace std::literals;
const auto bits = { "https:"sv, "//"sv, "cppreference"sv, "."sv, "com"sv };
for (char const c : bits | std::views::join) std::cout << c; // Error 1
std::cout << '\n';
const std::vector<std::vector<int>> v{ {1,2}, {3,4,5}, {6}, {7,8,9} };
auto jv = std::ranges::join_view(v); // Error 2
for (int const e : jv) std::cout << e << ' ';
std::cout << '\n';
}
I get errors:
1. No member named 'views' in namespace 'std'
2. No member named 'join_view' in namespace 'std::ranges'
That reference site says these things are available "since C 20". I have my language build setting at the maximum: C 2b
. The clang --version
reports: Apple clang version 14.0.0 (clang-1400.0.29.102).
Is there a way to make this work with Xcode's C compiler?
CodePudding user response:
AppleClang does not support C views. See the red boxes in the 4th column on C compiler support.