Boost logo

Boost :

Subject: Re: [boost] [Bug Sprint] [variant] #2839 ambiguous swap call
From: Joseph Gauterin (joseph.gauterin_at_[hidden])
Date: 2009-06-03 14:38:51


>I'm pretty sure the intent of the code is to replace the generic
>swap-by-copy-assignment std::swap template

The intent is to replace std::swap with a call a specialized swap (via
ADL) or to call boost::detail::move_swap::swap otherwise. std::swap
will never be called from that function, unless std::swap is picked up
by ADL - in which case it probably *is* specialized for the type being
swapped. By making boost::detail::move_swap::swap less specialized
than std::swap, you can stop the ambiguity that happens only in this
case.

For example, in your test case where you are swapping a std::vector
you actually want std::swap to be called, as it is the specialized
version (the standard defines the effect of template <class T, class
Alloc> std::swap(std::vector<T,Alloc>& x, std::vector<T,Alloc>& y); to
be x.swap(y)).

For clarity; It's boost::detail::move_swap::swap that needs changing
to have two tempalte parameters.

Joe.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk