std::forward_list<T,Allocator>::sort
void sort(); |
(1) | (since C++11) (constexpr since C++26) |
template< class Compare > void sort( Compare comp ); |
(2) | (since C++11) (constexpr since C++26) |
Sorts the elements and preserves the order of equivalent elements. If an exception is thrown, the order of elements in *this is unspecified.
No references or iterators become invalidated.
Contents |
[edit] Parameters
| comp | - | comparison function object (i.e. an object that satisfies the requirements of Compare) which returns true if the first argument is less than (i.e. is ordered before) the second. The signature of the comparison function should be equivalent to the following: bool cmp(const Type1& a, const Type2& b); While the signature does not need to have const&, the function must not modify the objects passed to it and must be able to accept all values of type (possibly const) |
| Type requirements | ||
-Compare must meet the requirements of Compare.
| ||
[edit] Complexity
Given N as std::distance(begin(), end()):