Boost logo

Boost :

Subject: [boost] [tuple] swap (also includes question about [sorting])
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2009-05-08 15:12:38

Thanks to Marcin Zalewski, the problem in my last email has been tracked
down to the inability to swap boost::tuples that contain references.
There have been a couple of proposals to add that:

but it appears that none of them has made it into Boost. This feature is
important because of sorting data structures using zip_iterators as in my
previous message:

and the older posts:

In particular, std::swap (from GCC 4.0.1) does not work correctly on the
result of dereferencing a zip_iterator, which is a Boost tuple of
references. The std::swap function does not work at all (fails at compile
time) because the result of operator* is not a non-const reference, and
std::iter_swap tries to use assignment between the tuples, producing
incorrect answers at run time. Is it true that there is no
standards-compliant way to solve this problem? If so, would that be a
good justification for Boost.Sorting to include an algorithm similar to
std::sort but that handles more generalized swappable types?

-- Jeremiah Willcock

Boost list run by bdawes at, gregod at, cpdaniel at, john at