Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2003-08-07 06:02:13


Alisdair Meredith wrote:
> David Abrahams wrote:
>
>> Err, I don't get it. It seems to me that you only need the hack if
>> you're going to *specialize* swap. *Using* std::swap should work
>> just fine.
>
> OK, that's because I was confused <g>
> The following is really a minimal example, so I can be clearer this
> time:
>
>
>
> #include <boost/shared_ptr.hpp>

#include <algorithm>

It is unspecified whether shared_ptr.hpp will do it for you.

> class empty
> {
> };
>
> //#define DEMONSTRATE_BUG
> # if defined( DEMONSTRATE_BUG )
> namespace std
> {
> template<>
> void swap( empty &lhs, empty &rhs )
> {
> }
>
> }
> # endif

I think that this specialization is ill-formed if the primary swap<> isn't
in std. Your code is broken by STLport's tricks, even though it looks
correct. :-)

Try

template<> void std::swap( empty &lhs, empty &rhs )
{
}

instead and see if it works. (I think it's broken too but the compiler may
like it better.)


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