Boost logo

Boost :

From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-07-26 14:22:33


Niels Dekker - mail address until 2008-12-31 wrote:
> Steven Watanabe wrote:
>> Adding overloads to namespace boost is not guaranteed to work either.
>> template<class T>
>> void foo(T& t1, T&t2) {
>> boost::swap(t1, t2);
>> }
>> class X {};
>> namespace boost {
>> void swap(X&, X&); // not found by foo.
>> }
> Thanks, Steven! So the user should make sure that all of her custom
> boost swap overloads are declared, /before/ including any function that
> actually calls boost::swap... right?

Yes, this should work, but it is hard to guarantee.

> I
> tend to think that it's "morally right" to have the end-user provide
> template specializations of boost function templates, but I'm not sure
> about overloads... what do you think?

I don't see a problem in this case.

> Unfortunately this is
> not the case for msvc-7.1: msvc-7.1 fails on both
> "specialized_in_global" and "specialized_in_other". It just doesn't
> seem to do ADL on template arguments. :-(

msvc-7.1 is one of the compilers that does all look up in phase 2, I think.

namespace users_namespace {
    class X {};
    void swap(X&, X&);

namespace boost {
    using users_namespace::swap;

We have to use a #if to avoid an ODR violation for
compilers that implement two-phase name lookup correctly.

In Christ,
Steven Watanabe

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