Standard C++ Library Reference ISO/IEC (VERSION3)

otherwise be copied to adjacent elements, the function copies only the element from the ordered
range [first1, last1) and skips the other. An element from one sequence that has
equivalent ordering with no element from the other sequence is copied from the ordered range
[first1, last1) and skipped from the other. Thus, the function merges two ordered
sequences to form another ordered sequence that is effectively the difference of two sets.
If dest and first1 designate regions of storage, the range [dest, dest + K) must not
overlap the range [first1, last1). If dest and first2 designate regions of storage, the
range [dest, dest + K) must not overlap the range [first2, last2). The function
evaluates the ordering predicate X < Y at most 2 * ((last1 - first1) + (last2 -
first2)) - 1 times.
The second template function behaves the same, except that it replaces operator<(X, Y)
with pred(X, Y).
set_intersection
template<class InIt1, class InIt2, class OutIt>
OutIt set_intersection(InIt1 first1, InIt1 last1,
InIt2 first2, InIt2 last2, OutIt dest);
template<class InIt1, class InIt2, class OutIt,
class Pr>
OutIt set_intersection(InIt1 first1, InIt1 last1,
InIt2 first2, InIt2 last2, OutIt dest, Pr pred);
The first template function alternately copies values from two sequences designated by iterators
in the ranges [first1, last1) and [first2, last2), both ordered by operator<,
to form a merged sequence of length K beginning at dest, also ordered by operator<. The
function then returns dest + K.
The merge occurs without altering the relative order of elements within either sequence.
Moreover, for two elements from different sequences that have equivalent ordering that would
otherwise be copied to adjacent elements, the function copies only the element from the ordered
range [first1, last1) and skips the other. An element from one sequence that has
equivalent ordering with no element from the other sequence is also skipped. Thus, the function
merges two ordered sequences to form another ordered sequence that is effectively the
intersection of two sets.
If dest and first1 designate regions of storage, the range [dest, dest + K) must not
overlap the range [first1, last1). If dest and first2 designate regions of storage, the
range [dest, dest + K) must not overlap the range [first2, last2). The function
evaluates the ordering predicate X < Y at most 2 * ((last1 - first1) + (last2 -
first2)) - 1 times.
The second template function behaves the same, except that it replaces operator<(X, Y)
with pred(X, Y).