Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-10-30 07:49:58

From: "George A. Heintzelman" <georgeh_at_[hidden]>
> > When you introduce a function 'type' that is intended to take advantage
> > ADL, you are effectively claiming ownership on the name 'type' in all
> > reachable namespaces.
> Yes, this is so. The question is, what should the set of reachable
> namespaces be? Do we really want deriving from boost::noncopyable to
> pull in the whole of boost's interface? That's really what I'm arguing
> against in the end.

It depends on the circumstances. I agree that deriving from
boost::noncopyable probably shouldn't add boost to the reachable namespaces.

On the other hand, sometimes it is necessary to add the base class namespace
to the list, if the base class provides a service via ADL. Consider

namespace boost
    void intrusive_ptr_add_ref(counted_base *);

The intent here is to enable intrusive_ptr_add_ref to work on derived

I don't want to downplay the importance of your proposed technique. I have
used it in the past as a matter of style; I dropped it because compilers
often had problems with using declarations, especially when applied to
template names. The technique is good, and useful. But it doesn't solve the
problem in general, only the portion that you have encountered. Consider:

std::vector< boost::shared_ptr<int> > v;


Will this work? Nobody knows.

But wait, there's more. You are probably using g++, right? This compiler
insists on making all names visible to ADL. The usual approach is to make
only function (template) names visible. Since boost::type is a class
template, it obviously cannot be used legally in a type(...) expression, and
making it invisible to ADL solves your particular problem.

This is core active issue 218.

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