std::sort
has complexity requirements, which is O(n log n).
Besides common QuickSort or IntroSort, other algorithms would fit it.
Sure Bubble Sort with O(n2) does not fit.
However, if we take a specialization for pointers to int
without explicit predicate. The number of iterations or comparisons cannot be observed, as there's no way to specialize operator<
or pointer indirection, and user's code is not allowed to specialize std::less
for int
s, and as the predicate isn't passed, it is std::less
/operator<
.
So can int*
predicate-less version be specialized to use Bubble Sort by some evil implementation of the STL?
This question is similar to Would it be legal to implement overloads of std::sort with radix sort?, but the answer points out that the Radix sort meets the requirements, so it is not what I intend to ask.
The actual intention is if the implementation is allowed to do optimizations, that are worse for complexity, but better for runtime. I want to focus on "if this is allowed" rather than "if this is possible to make faster implementation with worse complexity", that's why I picked Bubble Sort as clearly horrible example.