Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-10-29 06:51:13


From: "George A. Heintzelman" <georgeh_at_[hidden]>
> So, I was writing a new iterator today:
>
> namespace MyNS {
> class Iterator: public boost::bidirectional_iterator_helper<...> {
> };
>
> // I need some utility functions on the iterators:
> int type(Iterator it);
> };
>
> int main() {
> Iterator it;
> type(it);
> }
>
> Boom. The error I get is:
>
> `template<class T> class boost::type' is not a function, conflict with
`int MyNS::type(MyNS::Iterator)' in call to `type'
>
> So I went to my trusty standard and found out that, sure enough, it was
correct to reject this code according to the section on name-dependent
argument lookup (given that I had indirectly included boost/type.hpp). This
is because MyNS and boost are both associated namespaces of MyNS::Iterator.
>
> So... What this means is that deriving (however indirectly) from any
namespace entity means that all those names are now effectively poisoned for
the purpose of finding it via Koenig lookup. When that namespace is boost,
that could really become a problem.
>
> Is there anything I (or boost) can do?<

Yes, you can rename type() to something less collision prone. Functions that
are intended to be used via argument dependent lookup must have distinctive
names. "iterator_type" would be better, but probably not enough; use
something more descriptive.


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