Documentation of std::nth_element

Hi,

I'm using std::nth_element on vectors, some of them are pre-sorted and some are not. I found that my code implicitly assumes that vectors which are already sorted are not modified, but that is false.

I think the description would benefit from a small warning, e.g. "...elements following it are less. Note that pre-sorted ranges don't necessarily stay sorted".

Is there a way to submit such suggestions?

Best Regards,
Alexander
It's an unwarranted assumption to expect the employed algorithm to be limited in that way. If you need to keep an ordered container in order, you can do the initial test yourself with std::is_sorted (or possibly std::is_sorted_until).

At any rate, AFAIK this site is no longer being updated.
Last edited on
Which description from where?

If for the cplusplus.com site, then probably not as the site Reference section hasn't been updated for some years.
Last edited on
Topic archived. No new replies allowed.