Boost logo

Boost :

From: Alisdair Meredith (alisdair.meredith_at_[hidden])
Date: 2003-08-07 07:07:36


Peter Dimov wrote:

> 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. :-)

I think this is the consensus.

> 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.)

Has problems implementing functions inside namespaces with earlier BCBs
so I didn't think to try it. This is much better, as the compiler
rejects the swap straight away, so the error is found on the correct
line, rather than in shared_ptr <g>

I am still not clear on the 'best' solution though.
Clearly the quickest fix is to simply put the swap specialization in the
correct namespace.

However, boost code does not seem to specialize std::swap at all, but
rather provide its own swaps in namespace boost. Is this the preferred
approach? [using my own namespaces, obviously!]

No-throw swap operations are clearly important tool when we are worrying
about the exception guarantees, but I am not 100% clear on the 'correct'
way to do this anymore.

-- 
AlisdairM

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