iter_swap
Section: 24.2 [iterator.synopsis] Status: NAD Submitter: Alisdair Meredith Opened: 2010-02-16 Last modified: 2017-06-05
Priority: Not Prioritized
View all other issues in [iterator.synopsis].
View all issues with NAD status.
Discussion:
The iter_swap
function template appears in the
<algorithm>
header, yet its main use is in building further
algorithms, not calling existing ones. The main clients are implementers of data
structures and their iterators, so it seems most appropriate to place the
template in the <iterator>
header instead.
Note that this is not an issue for implementers of the standard library, as they rarely use the standard headers directly, designing a more fine-grained set of headers for their own internal use. This option is not available to customers of the standard library.
Note that we cannot remove iter_swap
from <algorithm>
without breaking code, but there is no reason we cannot offer the same
declaration via two standard headers. Alternatively, require
<algorithm>
to #include <iterator>
, but
introducing the dependency on the iterator adaptors seems un-necessary.
[ ]
Discussed possibly moving to <utility>
but don't like that. Some not seeing this
as a defect, and want to keep it in <algorithm>
. No one seems to feel strongly
about moving to <iterator>
.
[2017-02 in Kona, LEWG recommends NAD]
[2017-06-02 Issues Telecon]
Resolve as NAD
Proposed resolution:
Add the declaration of iter_swap
to the <iterator>
header synopsis (24.2 [iterator.synopsis]), with a note that it is
documented in clause 26 [algorithms].
... template <class T, size_t N> T* end(T (&array)[N]); // documented in 26 [algorithms] template<class ForwardIterator1, class ForwardIterator2> void iter_swap(ForwardIterator1 a, ForwardIterator2 b);