
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?

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

Hi bringiton, there is a nice Wikipedia article about 'argument dependent name lookup' AKA 'Koenig-lookup': http://en.wikipedia.org/wiki/Argument_dependent_name_lookup I think it generally is a very good idea *not* to use 'using namespace xyz' in code examples, as long as the (confusing) lookup mechanisms are not the subject of the example. Martin. bringiton bringiton schrieb:
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? _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Hi, I have a problem with Mutable queue. I'm trying to store edge descriptors there, but sometimes (!) my program fails with segmentation fault at mutable_queue.hpp:94 when I'm trying to push an edge_descriptor into the queue. There is a way how I declare and create the queue (entire code is to long to include): typedef typename property_traits<CostMap>::value_type C; typedef indirect_cmp<CostMap, CompareFunction> IndirectCmp; IndirectCmp icmp(cost, compare); typedef mutable_queue<Edge, std::vector<Edge>, IndirectCmp, IndexMap> MutableQueue; MutableQueue Q(num_edges(g), icmp, index_map); where g is VertexAndEdgeListGraph, compare is std::less<C>(), cost is weight_map(get(&Edge::cost, graph)), index_map is property_map<graph_t, edge_index_t Edge::*>::type edge_index = get(&Edge::index, graph) My program fails here: Q.push(s); where Q is declared above s is typename graph_traits<IncidenceGraph>::edge_descriptor s I guess, something is wrong with the Index Map. Please, help me! Thanks in advance, Anton.
participants (4)
-
Anton A. Patrushev
-
bringiton bringiton
-
Douglas Gregor
-
Martin Pasdzierny