The LWG met in Santa Cruz and reviewed n1387. The consensus to come out of that meeting is that we want to create " swappable requirements" and then endow specific algorithms with this new requirement. This paper is an attempt to address that desire.
Add new section: 20.1.6
20.1.6 - Swappable requirements [lib.swappable.requirements]
-1- In the following Table ??, T is a non-const type to be supplied by a C++ program instantiating a template, t and u are values of type T.
Swappable requirements
expression
return type
post-condition
swap(t, u)
void
t has the value originally held by u, and u has the value originally held by t
-2- The swappable requirement is met by satisfying one or more of the following conditions:
a. T is swappable if T is copyconstructible and assignable.
b. T is swappable if a namespace scope function named swap exists in the same namespace as the definition of T, such that the expression swap(t, u) is valid and has the semantics described in Table??.
25.2.2: swap_ranges
-4- Requires: The two ranges [first1 ,last1 )and [first2 ,first2 + ( last1 -first1 )) shall not overlap. The type referred to by ForwardIterator1 must be the same type referred to by ForwardIterator2, and that type must be swappable.
25.2.2: iter_swap
-7- Effects: Calls swap with the values pointed to by the two iterators a and b.
-8- Requires: The type referred to by ForwardIterator1 must be the same type referred to by ForwardIterator2, and that type must be swappable.
25.2.9: reverse
-0- Requires: The type referred to by BidirectionalIterator must be swappable.
25.2.10: rotate
-3- Requires: [first ,middle )and [middle ,last )are valid ranges. The type referred to by ForwardIterator must be swappable.
25.2.11: random_shuffle
-4- Requires: The type referred to by RandomAccessIterator must be swappable.
25.2.12: partition
-4- Requires: The type referred to by BidirectionalIterator must be swappable.
25.2.12: stable_partition
-7- Requires: The type referred to by BidirectionalIterator must be swappable.
25.3.1.1: sort
-3- Requires: The type referred to by RandomAccessIterator must be swappable.
25.3.1.2: stable_sort
-4- Requires: The type referred to by RandomAccessIterator must be swappable.
25.3.1.3: partial_sort
-3- Requires: The type referred to by RandomAccessIterator must be swappable.
25.3.1.4: partial_sort_copy
-4- Requires: The type referred to by RandomAccessIterator must be swappable.
25.3.2: nth_element
-3- Requires: The type referred to by RandomAccessIterator must be swappable.
25.3.4: inplace_merge
-9- Requires: The type referred to by BidirectionalIterator must be swappable.
25.3.6.2: pop_heap
-1- Requires: The range [first ,last )shall be a valid heap. The type referred to by RandomAccessIterator must be swappable.
25.3.6.4: sort_heap
-4- Requires: The type referred to by RandomAccessIterator must be swappable.
25.3.9: next_permutation
-?- Requires: The type referred to by BidirectionalIterator must be swappable.
25.3.9: prev_permutation
-6- Requires: The type referred to by BidirectionalIterator must be swappable.
26.3.3.3/1: valarray transcendentals
-1- Each of these functions may only be instantiated for a type T to which a unique function with the indicated name can be applied (unqualified). This function shall return a value which is of type T or which can be unambiguously converted to type T .