]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/parameter/test/literate/predicate-requirements0.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / parameter / test / literate / predicate-requirements0.cpp
1
2 #include <boost/parameter.hpp>
3 #include <boost/graph/adjacency_list.hpp>
4 #include <boost/graph/depth_first_search.hpp>
5
6 BOOST_PARAMETER_NAME((_graph, graphs) graph)
7 BOOST_PARAMETER_NAME((_visitor, graphs) visitor)
8 BOOST_PARAMETER_NAME((_root_vertex, graphs) root_vertex)
9 BOOST_PARAMETER_NAME((_index_map, graphs) index_map)
10 BOOST_PARAMETER_NAME((_color_map, graphs) color_map)
11
12 using boost::mpl::_;
13 // We first need to define a few metafunction that we use in the
14 // predicates below.
15
16 template <class G>
17 struct traversal_category
18 {
19 typedef typename boost::graph_traits<G>::traversal_category type;
20 };
21
22 template <class G>
23 struct vertex_descriptor
24 {
25 typedef typename boost::graph_traits<G>::vertex_descriptor type;
26 };
27
28 template <class G>
29 struct value_type
30 {
31 typedef typename boost::property_traits<G>::value_type type;
32 };
33
34 template <class G>
35 struct key_type
36 {
37 typedef typename boost::property_traits<G>::key_type type;
38 };
39
40 template<class Size, class IndexMap>
41 boost::iterator_property_map<
42 boost::default_color_type*, IndexMap
43 , boost::default_color_type, boost::default_color_type&
44 >
45 default_color_map(Size num_vertices, IndexMap const& index_map)
46 {
47 std::vector<boost::default_color_type> colors(num_vertices);
48 return &colors[0];
49 }
50
51 BOOST_PARAMETER_FUNCTION(
52 (void), depth_first_search, graphs
53
54 , (required
55 (graph
56 , *(boost::mpl::and_<
57 boost::is_convertible<
58 traversal_category<_>, boost::incidence_graph_tag
59 >
60 , boost::is_convertible<
61 traversal_category<_>, boost::vertex_list_graph_tag
62 >
63 >) ))
64
65 (optional
66 (visitor, *, boost::dfs_visitor<>()) // not checkable
67
68 (root_vertex
69 , (vertex_descriptor<graphs::graph::_>)
70 , *vertices(graph).first)
71
72 (index_map
73 , *(boost::mpl::and_<
74 boost::is_integral<value_type<_> >
75 , boost::is_same<
76 vertex_descriptor<graphs::graph::_>, key_type<_>
77 >
78 >)
79 , get(boost::vertex_index,graph))
80
81 (in_out(color_map)
82 , *(boost::is_same<
83 vertex_descriptor<graphs::graph::_>, key_type<_>
84 >)
85 , default_color_map(num_vertices(graph), index_map) )
86 )
87 )
88 {}
89
90 int main()
91 {
92 typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS> G;
93
94 enum {u, v, w, x, y, z, N};
95 typedef std::pair<int, int> E;
96 E edges[] = {E(u, v), E(u, x), E(x, v), E(y, x), E(v, y), E(w, y),
97 E(w,z), E(z, z)};
98 G g(edges, edges + sizeof(edges) / sizeof(E), N);
99
100 ::depth_first_search(g);
101 ::depth_first_search(g, _root_vertex = (int)x);
102 }
103