Issue
I am trying to compile a program that uses std::ranges::sort()
with clang++16, but I am receiving an error when compiling.
According to https://en.cppreference.com/w/cpp/compiler_support/20, the One Ranges Proposal is implemented in Clangs’ libc++ version 13 (partial), 15 (requires -fexperimental-library
flag), and 16 (without the flag). I installed clang++16 with sudo pkg install llvm16
, but when trying to compile the application it errors out with “no matching function for call to ‘sort’”.
Minimal Reproducible Example
#include <algorithm>
#include <ranges>
#include <array>
int main()
{
std::array s {5, 7, 4, 2, 8, 6, 1, 9, 0, 3};
std::ranges::sort(s);
}
Trying to compile with clang++16 -std=c++20 -stdlib=libc++ test.cpp -o test
results in this error:
test.cpp:9:15: error: no type named 'sort' in namespace 'std::ranges'
std::ranges::sort(s);
~~~~~~~~~~~~~^
1 error generated.
Question
What am I doing wrong?