Boost logo

Boost :

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


David Abrahams wrote:

> I'm trying to say that I think it's the wrong patch. The right patch
> would put the swap specialization into _STL::.

I'm weighing up the 'correct' solution with the 'practical' solution.

Correct would be, as you say, fix all the code everywhere else
specializing std::swap, including code in other vendor supplied
headers. (This may cause friction with 3rd party vendors, but that is
their problem not Boost's) Likewise, we are in perfect control of our
own source to 'do the right thing' ourselves.

The practical approach says that the error the compiler reports always
points to the place using std::swap, and not the place defining the
specialization. This means the errors always point to boost headers, no
matter how unjust. It also makes tracking the header causing the
problem a nasty case of recursively checking every header and those it
includes to locate the source of the problem. Various search tools can
simplify the task, but there is still an element of
needle-in-a-haystack.

Finally there is the problem of explaining all this to users the first
time they hit the problem, as 'the bug is in boost code. See, the
compiler says so!' I guess as the problem is not reported regularly to
the user list it is still quite rarely encountered, but at the least we
should put up an entry on the Wiki to point people to (and as chief
trouble maker I guess that is my job!)

I tried searching the Boost source for places where Boost itself
provided swap implementations, and discovered that these are always
placed in namespace boost and not std. As this pattern is adopted
everywhere I am assuming I have missed some discussion/guideline
outlining this as best practice. Is there a reference/link I could read
up before putting an entry in the Wiki?

-- 
AlisdairM
Team Thai Kingdom

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