writing-the-function0.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #include <boost/parameter/name.hpp>
  2. BOOST_PARAMETER_NAME(graph)
  3. BOOST_PARAMETER_NAME(visitor)
  4. BOOST_PARAMETER_NAME(root_vertex)
  5. BOOST_PARAMETER_NAME(index_map)
  6. BOOST_PARAMETER_NAME(in_out(color_map))
  7. namespace boost {
  8. template <typename T = int>
  9. struct dfs_visitor
  10. {
  11. };
  12. int vertex_index = 0;
  13. }
  14. #include <boost/parameter/preprocessor.hpp>
  15. namespace graphs {
  16. BOOST_PARAMETER_FUNCTION(
  17. (void), // 1. parenthesized return type
  18. depth_first_search, // 2. name of the function template
  19. tag, // 3. namespace of tag types
  20. (required (graph, *) ) // 4. one required parameter, and
  21. (optional // four optional parameters, with defaults
  22. (visitor, *, boost::dfs_visitor<>())
  23. (root_vertex, *, *vertices(graph).first)
  24. (index_map, *, get(boost::vertex_index,graph))
  25. (in_out(color_map), *,
  26. default_color_map(num_vertices(graph), index_map)
  27. )
  28. )
  29. )
  30. {
  31. // ... body of function goes here...
  32. // use graph, visitor, index_map, and color_map
  33. }
  34. }