How does std::sort implement the swap operation using iterators only?

algorithm, c++, stl

Solution

How can I create a third variable without knowing the data type?

Use `std::iterator_traits<ITERATOR>::value_type`

Problem

How can I implement for instance the following ``` template <typename ITERATOR> void Swap (ITERATOR a, ITERATOR b) { ... } ``` so that Swap(a, b) swaps the values pointed at by a and b. In other words: How can I create a third variable without knowing the data type?

Original source