fork(1) download
  1.  
  2. #include <iostream>
  3.  
  4. #include <boost/graph/undirected_graph.hpp>
  5. #include <boost/range/iterator_range.hpp>
  6.  
  7. using std::cout;
  8.  
  9. int main() {
  10. boost::undirected_graph<boost::no_property> g;
  11.  
  12. auto a = g.add_vertex();
  13. auto b = g.add_vertex();
  14. auto c = g.add_vertex();
  15.  
  16. add_edge(a, b, g);
  17. add_edge(b, c, g);
  18.  
  19. for(auto v : make_iterator_range(vertices(g))) {
  20. cout << v << " has " << degree(v, g) << " neighbor(s): ";
  21. for(auto w : make_iterator_range(adjacent_vertices(v, g))) cout << w << ' ';
  22. cout << '\n';
  23. }
  24. return 0;
  25. }
  26.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:19:47: error: 'make_iterator_range' was not declared in this scope
   for(auto v : make_iterator_range(vertices(g))) {
                                               ^
prog.cpp:19:47: note: suggested alternative:
In file included from /usr/include/boost/range/iterator_range.hpp:13:0,
                 from /usr/include/boost/range/irange.hpp:16,
                 from /usr/include/boost/graph/detail/adjacency_list.hpp:21,
                 from /usr/include/boost/graph/adjacency_list.hpp:246,
                 from /usr/include/boost/graph/undirected_graph.hpp:10,
                 from prog.cpp:4:
/usr/include/boost/range/iterator_range_core.hpp:622:9: note:   'boost::make_iterator_range'
         make_iterator_range( const Range& r,
         ^
stdout
Standard output is empty