C++20 new feature

So now that std::ranges is a thing, we can write std::ranges::sort(seq), instead of std::sort(seq.begin(), seq.end());

The problem is, that most of the functions in std, and std::ranges have conflicts.

So for example

#include <bits/stdc++.h>
using namespace std;
using namespace std::ranges;
using ll = long long int;
int main(){
    int n;
    vector<int> seq(n);
    for(auto &x : seq) cin>>x;
    for(auto &x : seq) cout<<x<<" ";

will not compile, as sort is ambigous. Is there anyway to overcome this, so C++ users will finally be able to write sort(seq).



isn’t we can define sort(a) = sort(a.begin() , a.end()) ?

1 Like