On 16-09-2015 19:40, Francois Duranleau wrote:
The is_sorted check would be in an assert, so it would go away in release builds (this is just validation of precondition, much like we would assert in std::vector<T>::operator[] for out-of-range indices).
Yes, of course in an assertion.
Granted, this check is costly, and ideally we would like to have control on how expensive we allow validation of preconditions to be. Personally, I wouldn't mind if the check is not done at all. I was merely suggesting in which case we might add this check.
Well, you already paid at least O(n) time to build the container that you are moving from. You won't get a different complexity because of this check. On the other hand, you might catch a lot of accidental problems (say, not being sorted or being sorted with the wrong predicate). These operations allow the user to break the invariant of the container, an assertion would be the minimum to expect as a guard against this. kind regards Thorsten