How is my C++11 allowing me to use std::unique and std::erase?
I found this nice two-line code for sorting and de-duplicating a vector at StackOverflow. Beats writing an algo from scratch.
sort( vec.begin(), vec.end() );
vec.erase( unique( vec.begin(), vec.end() ), vec.end() );
I used it in my code, and it compiles ... in C++11
How the heck is it compiling if
https://en.cppreference.com/w/cpp/algorithm/unique
and
https://en.cppreference.com/w/cpp/container/vector/erase2
say that unique and erase have only existed since C++17 and C++20 respectively?
Am I misunderstanding that documentation, or might my C++11 have some "we think this will be in the next standard" enhancements in it?
Thanks!
Posted Apr 8, 2025, 9:09 PM UTC
011