3 ms·
std::sort requires random-access iterators, which std::list - being a list - can't supply. std::list's iterator type: http://en.cppreference.com/w/cpp/containe
by to3m 11y ago
std::sort requires random-access iterators, which std::list - being a list - can't supply.
std::list's iterator type: http://en.cppreference.com/w/cpp/container/list http://en.cppreference.com/w/cpp/container/list
std::sort's iterator requirements: http://en.cppreference.com/w/cpp/algorithm/sort http://en.cppreference.com/w/cpp/algorithm/sort
All the different types of iterator: http://en.cppreference.com/w/cpp/iterator http://en.cppreference.com/w/cpp/iterator
(This might seem like needless nitpicking to some; to me, it's more like knowing why you can't, say, seek on a socket.)
- prewett 11y agoYeah, I know why. Problem is, it is a bad design. I don't work for the API, the API works for me. Conceptually sorting a list is the same as sorting a vector, so it should look the same in the code. The fact that it may require a different algorithm underneath is what the API is there to figure out for me. Other languages and APIs (including Qt) don't have problems like this, hence my complaint.