Книга: Standard Template Library Programmer
iter_swap
Разделы на этой странице:
iter_swap
Category: algorithms
Component type: function
Prototype
template <class ForwardIterator1, class ForwardIterator 2>
inline void iter_swap(ForwardIterator1 a, ForwardIterator2 b);
Description
Equivalent to swap(*a, *b). [1]
Definition
Declared in algo.h. The implementation is in algobase.h.
Requirements on types
• ForwardIterator1 and ForwardIterator2 are models of Forward Iterator.
• ForwardIterator1 and ForwardIterator2 are mutable.
• ForwardIterator1 and ForwardIterator2 have the same value type.
Preconditions
• ForwardIterator1 and ForwardIterator2 are dereferenceable.
Complexity
See swap for a discussion.
Example
int x = 1;
int y = 2;
assert(x == 1 && y == 2);
iter_swap(&x, &y);
assert(x == 2 && y == 1);
Notes
[1] Strictly speaking, iter_swap is redundant. It exists only for technical reasons: in some circumstances, some compilers have difficulty performing the type deduction required to interpret swap(*a, *b).
See also
swap, swap_ranges
- Skipping an Iteration
- Swap
- swap
- swap_ranges
- Working with OpenOffice.org Writer
- Iterators
- 15.7.4 Using Condition Variables to Synchronize between Readers and Writers
- 15.7.6 Implementing Reader-Writer Locks Using Condition Variables
- Indexers and Iterators
- reverse_bidirectional_iterator
- iterator_traits
- Глава 5 Работа с программой PiterGrapho