3 ms·
I _believe_ std::sort used to be more complicated because you had to define a class with a compare method for custom comparison functions, or something like tha
by jstimpfle 5y ago
I _believe_ std::sort used to be more complicated because you had to define a class with a compare method for custom comparison functions, or something like that. Looking here https://en.cppreference.com/w/cpp/algorithm/sort https://en.cppreference.com/w/cpp/algorithm/sort , I cannot be arsed to find out what works since which version of C++. Come on, look at that link and tell me with a straight face you can't grok the qsort() signature much more easily than that mess.
Other than that, the STL is generally slower compiling compared to only including plain C headers, which is also taxing on the "ease of use" department.
- dataangel 5y ago`sort(begin(foo), end(foo))` Has worked in C++ for ~25 years as long as `foo` is a container of items with an `operator<`. It has never required defining a separate class. It will also optimize better than qsort when qsort fails to inline.
- slavik81 5y agoYour main point is correct, but std::begin and std::end were added in C++11. You would have used pointers or begin/end member functions for most of those 25 years.
- deleted 5y ago[deleted]
- deleted 5y ago[deleted]