Consider this code (or a live example ):
#include <iostream> #include <boost/graph/adjacency_list.hpp> #include <boost/range/iterator_range.hpp> using std::cout; int main() { boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS> g; add_edge(0, 1, g); add_edge(1, 2, g); for(auto v : make_iterator_range(vertices(g))) { cout << v << " has " << degree(v, g) << " neighbor(s): "; for(auto w : make_iterator_range(adjacent_vertices(v, g))) cout << w << ' '; cout << '\n'; } return 0; }
Why are the add_edge , make_iterator_range , vertices , degree and adjacent_vertices functions performed from the Boost library without the boost:: namespace prefix?
What is most unpleasant for me is that, depending on the situation, the prefix is ββreally needed. Here is an example where using a different chart structure leads to a compilation error, which can be fixed using the boost::make_iterator_range .
I looked at the BGL documentation for a bit, but found nothing on this. Is this my mistake or are some BGL headers polluting the global namespace? Is it design or is it a mistake?
c ++ boost argument-dependent-lookup boost-graph
arekolek
source share