Boost logo

Boost Users :

From: Douglas Gregor (dgregor_at_[hidden])
Date: 2007-06-14 09:28:56


bringiton bringiton wrote:
> I've removed the using namespace boost from the astar graph cities
> example. (I prefer to define namespaces explicitly).
>
> //using namespace boost;
>
> I've added boost:: to all the type names and it all compiles fine.
>
> However, some functions compile without the namespace. ie the following line:
>
> WeightMap weightmap = get(boost::edge_weight, g);
>
> Can someone please explain why I dont need a boost:: infront of the get?
>

This is due to Argument Dependent Lookup, or ADL. Since the types of 'g'
and 'boost::edge_weight' live in the namespace 'boost', the unqualified
call to 'get' will look for the name 'get' within namespace 'boost'.
There's some more information about ADL here:

http://en.wikipedia.org/wiki/Argument_dependent_name_lookup

  - Doug


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net