I ran the following code
vector<int> randomIntegers = generateIntegers(10); // Generates 10 integers
std::ranges::sort(randomIntegers);
When I compile with g++ -std=c++20 file.cpp
, I get
error: 'sort' is not a member of 'std::ranges'; did you mean 'std::sort'?
gcc --version
: gcc 10.2.0g++ --version
: g++ 10.2.0
Why is sort not a member? I'm using VScode intellisense, and it shows methods such as advance
,begin
,common_view
. But not sort.
To get access to
std::ranges::sort
you need to#include <algorithm>
:Demo