std::list<T,Allocator>::merge (3) - Linux Manuals
void merge( list& other ); (1)
void merge( list&& other ); (1) (since C++11)
template <class Compare> (2)
void merge( list& other, Compare comp );
template <class Compare> (2) (since C++11)
void merge( list&& other, Compare comp );
Merges two sorted lists into one. The lists should be sorted into ascending order.
No elements are copied. The container other becomes empty after the operation. The function does nothing if other refers to the same object as *this. If get_allocator() != other.get_allocator(), the behavior is undefined. No iterators or references become invalidated, except that the iterators of moved elements now refer into *this, not into other. The first version uses operator< to compare the elements, the second version uses the given comparison function comp.
This operation is stable: for equivalent elements in the two lists, the elements from *this shall always precede the elements from other, and the order of equivalent elements of *this and other does not change.
other - another container to merge
comp - 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) Type1 and Type2 regardless of value_category (thus, Type1 & is not allowed
If an exception is thrown, this function has no effect (strong exception guarantee), except if the exception comes from the comparison function.
at most std::distance(begin(), end()) + std::distance(other.begin(), other.end()) - 1 comparisons.
// Run this code
splice (public member function)