Name

set_symmetric_difference function template — Computes symmetric difference of sorted ranges

Synopsis

template<typename InIter1, typename InIter2, typename OutIter>
  OutIter set_symmetric_difference(InIter1 first1, InIter1 last1, InIter2 first2,
                                   InIter2 last2, OutIter result); 
template<typename InIter1, typename InIter2, typename OutIter, typename Compare>
  OutIter set_symmetric_difference(InIter1 first1, InIter1 last1, InIter2 first2,
                                   InIter2 last2, OutIter result, Compare comp);

The set_symmetric_difference function template merges elements from the sorted ranges [first1, last1) and [first2, last2), copying the sorted, merged results to the range starting at result. Only those elements that are not also present in the sorted range [first2, last2) are copied from [first1, last1), and only those not present in the range [first1, last1) are copied from [first2, last2). An iterator that points to one past the end of the result range is returned.

The result range must not overlap either source range.

The first version compares items using the < operator. The second version uses comp(X, Y) to test whether X < Y.

Figure 13-19 shows an example of a set symmetric difference using multisets.

Computing the symmetric difference between two sets
Figure 13-19. Computing the symmetric difference between two sets

Technical Notes

Precondition: !(*(i + 1) < *i) for all i in [first1, last1 - 1) and !(*(j + 1) < *j) for all j in [first2, last2 - 1).

Postcondition: ...

Get C++ In a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.