From 0a5c9360deffb6e4ca99ce212de2883cc031ea4e Mon Sep 17 00:00:00 2001 From: Jeremy Siek Date: Mon, 20 Nov 2000 18:17:52 +0000 Subject: [PATCH] some concept checking changes as per review comments [SVN r8268] --- examples/concept_checks.cpp | 44 +++++----- .../graph/bellman_ford_shortest_paths.hpp | 21 ++--- include/boost/graph/breadth_first_search.hpp | 13 +-- include/boost/graph/depth_first_search.hpp | 6 +- include/boost/graph/graph_concepts.hpp | 82 +++++++++---------- include/boost/pending/stringtok.hpp | 3 +- 6 files changed, 86 insertions(+), 83 deletions(-) diff --git a/examples/concept_checks.cpp b/examples/concept_checks.cpp index 9b7c3d96..bd548adc 100644 --- a/examples/concept_checks.cpp +++ b/examples/concept_checks.cpp @@ -28,7 +28,7 @@ #include // -// These concept checks verify that the GGCL classes implement the +// These concept checks verify that the BGL classes implement the // complete interfaces defined in the graph concepts. The concept // checks are also useful for verifying whether user-defined graph // classes satisfy the desired graph concepts. Note that these concept @@ -48,14 +48,14 @@ main(int,char*[]) > Graph; typedef graph_traits::vertex_descriptor Vertex; typedef graph_traits::edge_descriptor Edge; - REQUIRE(Graph, VertexAndEdgeListGraph); - REQUIRE(Graph, MutableGraph); - REQUIRE3(Graph, Vertex, vertex_color_t, PropertyGraph); - REQUIRE3(Graph, Edge, edge_weight_t, PropertyGraph); + BOOST_FUNCTION_REQUIRES(Graph, VertexAndEdgeListGraphConcept); + BOOST_FUNCTION_REQUIRES(Graph, MutableGraphConcept); + BOOST_FUNCTION_REQUIRES3(Graph, Vertex, vertex_color_t, PropertyGraphConcept); + BOOST_FUNCTION_REQUIRES3(Graph, Edge, edge_weight_t, PropertyGraphConcept); // the builtin id property is readable but not writable typedef property_map::const_type IndexMap; typedef boost::graph_traits::vertex_descriptor Vertex; - REQUIRE2(IndexMap, Vertex, ReadablePropertyMap); + BOOST_FUNCTION_REQUIRES2(IndexMap, Vertex, ReadablePropertyMapConcept); } { typedef adjacency_list Graph; typedef graph_traits::vertex_descriptor Vertex; typedef graph_traits::edge_descriptor Edge; - REQUIRE(Graph, VertexAndEdgeListGraph); - REQUIRE(Graph, BidirectionalGraph); - REQUIRE(Graph, MutableGraph); - REQUIRE3(Graph, Vertex, vertex_color_t, PropertyGraph); - REQUIRE3(Graph, Edge, edge_weight_t, PropertyGraph); + BOOST_FUNCTION_REQUIRES(Graph, VertexAndEdgeListGraphConcept); + BOOST_FUNCTION_REQUIRES(Graph, BidirectionalGraphConcept); + BOOST_FUNCTION_REQUIRES(Graph, MutableGraphConcept); + BOOST_FUNCTION_REQUIRES3(Graph, Vertex, vertex_color_t, PropertyGraphConcept); + BOOST_FUNCTION_REQUIRES3(Graph, Edge, edge_weight_t, PropertyGraphConcept); // the builtin id property is readable but not writable typedef property_map::const_type IndexMap; typedef boost::graph_traits::vertex_descriptor Vertex; - REQUIRE2(IndexMap, Vertex, ReadablePropertyMap); + BOOST_FUNCTION_REQUIRES2(IndexMap, Vertex, ReadablePropertyMapConcept); } { typedef adjacency_list< listS, listS, directedS, @@ -81,10 +81,10 @@ main(int,char*[]) > Graph; typedef graph_traits::vertex_descriptor Vertex; typedef graph_traits::edge_descriptor Edge; - REQUIRE(Graph, VertexAndEdgeListGraph); - REQUIRE(Graph, MutableGraph); - REQUIRE3(Graph, Vertex, vertex_color_t, PropertyGraph); - REQUIRE3(Graph, Edge, edge_weight_t, PropertyGraph); + BOOST_FUNCTION_REQUIRES(Graph, VertexAndEdgeListGraphConcept); + BOOST_FUNCTION_REQUIRES(Graph, MutableGraphConcept); + BOOST_FUNCTION_REQUIRES3(Graph, Vertex, vertex_color_t, PropertyGraphConcept); + BOOST_FUNCTION_REQUIRES3(Graph, Edge, edge_weight_t, PropertyGraphConcept); } { typedef adjacency_list< listS, listS, undirectedS, @@ -93,19 +93,19 @@ main(int,char*[]) > Graph; typedef graph_traits::vertex_descriptor Vertex; typedef graph_traits::edge_descriptor Edge; - REQUIRE(Graph, VertexAndEdgeListGraph); - REQUIRE(Graph, MutableGraph); - REQUIRE3(Graph, Vertex, vertex_color_t, PropertyGraph); - REQUIRE3(Graph, Edge, edge_weight_t, PropertyGraph); + BOOST_FUNCTION_REQUIRES(Graph, VertexAndEdgeListGraphConcept); + BOOST_FUNCTION_REQUIRES(Graph, MutableGraphConcept); + BOOST_FUNCTION_REQUIRES3(Graph, Vertex, vertex_color_t, PropertyGraphConcept); + BOOST_FUNCTION_REQUIRES3(Graph, Edge, edge_weight_t, PropertyGraphConcept); } { typedef std::pair E; typedef edge_list EdgeList; - REQUIRE(EdgeList, EdgeListGraph); + BOOST_FUNCTION_REQUIRES(EdgeList, EdgeListGraphConcept); } { // Stanford GraphBase Graph typedef Graph* Graph; - REQUIRE(Graph, VertexListGraph); + BOOST_FUNCTION_REQUIRES(Graph, VertexListGraphConcept); } return 0; } diff --git a/include/boost/graph/bellman_ford_shortest_paths.hpp b/include/boost/graph/bellman_ford_shortest_paths.hpp index 097fabfd..15516708 100644 --- a/include/boost/graph/bellman_ford_shortest_paths.hpp +++ b/include/boost/graph/bellman_ford_shortest_paths.hpp @@ -104,12 +104,12 @@ namespace boost { typedef typename graph_traits::edge_descriptor Edge; typedef typename graph_traits::vertex_descriptor Vertex; - REQUIRE2(DistanceMap, Vertex, ReadWritePropertyMap); - REQUIRE2(WeightMap, Edge, ReadablePropertyMap); + BOOST_FUNCTION_REQUIRES2(DistanceMap, Vertex, ReadWritePropertyMapConcept); + BOOST_FUNCTION_REQUIRES2(WeightMap, Edge, ReadablePropertyMapConcept); typedef typename property_traits::value_type D_value; typedef typename property_traits::value_type W_value; - REQUIRE(D_value, LessThanComparable); - REQUIRE3(D_value, D_value, W_value, _OP_PLUS); + BOOST_FUNCTION_REQUIRES(D_value, ComparableConcept); + BOOST_FUNCTION_REQUIRES3(D_value, D_value, W_value, PlusOpConcept); std::plus combine; std::less compare; return bellman_ford_shortest_paths(g, N, weight, distance, @@ -126,15 +126,16 @@ namespace boost { BinaryPredicate compare, BellmanFordVisitor v) { - REQUIRE(EdgeListGraph, EdgeListGraph); - typedef typename graph_traits::edge_descriptor Edge; - typedef typename graph_traits::vertex_descriptor Vertex; - REQUIRE2(DistanceMap, Vertex, ReadWritePropertyMap); - REQUIRE2(WeightMap, Edge, ReadablePropertyMap); + BOOST_FUNCTION_REQUIRES(EdgeListGraph, EdgeListGraphConcept); + typedef graph_traits GTraits; + typedef typename GTraits::edge_descriptor Edge; + typedef typename GTraits::vertex_descriptor Vertex; + BOOST_FUNCTION_REQUIRES2(DistanceMap, Vertex, ReadWritePropertyMapConcept); + BOOST_FUNCTION_REQUIRES2(WeightMap, Edge, ReadablePropertyMapConcept); typedef typename property_traits::value_type D_value; typedef typename property_traits::value_type W_value; - typename graph_traits::edge_iterator i, end; + typename GTraits::edge_iterator i, end; for (Size k = 0; k < N; ++k) for (tie(i, end) = edges(g); i != end; ++i) { diff --git a/include/boost/graph/breadth_first_search.hpp b/include/boost/graph/breadth_first_search.hpp index b5dd9bfe..4e4d4ada 100644 --- a/include/boost/graph/breadth_first_search.hpp +++ b/include/boost/graph/breadth_first_search.hpp @@ -91,11 +91,12 @@ namespace boost { typename graph_traits::vertex_descriptor s, Buffer& Q, BFSVisitor vis, ColorMap color) { - REQUIRE(IncidenceGraph, IncidenceGraph); - typedef typename graph_traits::vertex_descriptor Vertex; - typedef typename graph_traits::edge_descriptor Edge; - REQUIRE2(BFSVisitor, IncidenceGraph, BFSVisitor); - REQUIRE2(ColorMap, Vertex, ReadWritePropertyMap); + BOOST_FUNCTION_REQUIRES(IncidenceGraph, IncidenceGraphConcept); + typedef graph_traits GTraits; + typedef typename GTraits::vertex_descriptor Vertex; + typedef typename GTraits::edge_descriptor Edge; + BOOST_FUNCTION_REQUIRES2(BFSVisitor, IncidenceGraph, BFSVisitorConcept); + BOOST_FUNCTION_REQUIRES2(ColorMap, Vertex, ReadWritePropertyMapConcept); typename property_traits::value_type c = get(color, s); put(color, s, gray(c)); @@ -105,7 +106,7 @@ namespace boost { Vertex u = Q.top(); Q.pop(); // pop before push to avoid problem if Q is priority_queue. vis.discover_vertex(u, g); - typename boost::graph_traits::out_edge_iterator + typename boost::GTraits::out_edge_iterator ei, ei_end; for (tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) { Edge e = *ei; diff --git a/include/boost/graph/depth_first_search.hpp b/include/boost/graph/depth_first_search.hpp index d07902e3..56917308 100644 --- a/include/boost/graph/depth_first_search.hpp +++ b/include/boost/graph/depth_first_search.hpp @@ -70,7 +70,7 @@ namespace boost { void depth_first_search(VertexListGraph& g, DFSVisitor vis, ColorMap color) { - REQUIRE2(DFSVisitor, VertexListGraph, DFSVisitor); + BOOST_FUNCTION_REQUIRES2(DFSVisitor, VertexListGraph, DFSVisitorConcept); typename property_traits::value_type c = get(color, *vertices(g).first); // value of c not used, just type @@ -91,8 +91,8 @@ namespace boost { typename graph_traits::vertex_descriptor u, DFSVisitor& vis, ColorMap color) { - REQUIRE(IncidenceGraph, IncidenceGraph); - REQUIRE2(DFSVisitor, IncidenceGraph, DFSVisitor); + BOOST_FUNCTION_REQUIRES(IncidenceGraph, IncidenceGraphConcept); + BOOST_FUNCTION_REQUIRES2(DFSVisitor, IncidenceGraph, DFSVisitorConcept); typename property_traits::value_type c = get(color, u); put(color, u, gray(c)); diff --git a/include/boost/graph/graph_concepts.hpp b/include/boost/graph/graph_concepts.hpp index 74917ce6..d3ba19d0 100644 --- a/include/boost/graph/graph_concepts.hpp +++ b/include/boost/graph/graph_concepts.hpp @@ -38,9 +38,9 @@ namespace boost { template - struct MultiPassInputIterator_concept { + struct MultiPassInputIteratorConcept { void constraints() { - REQUIRE(T, InputIterator); + BOOST_FUNCTION_REQUIRES(T, InputIteratorConcept); } }; @@ -48,7 +48,7 @@ namespace boost { // add directed_category in a couple places template - struct Graph_concept + struct GraphConcept { typedef typename graph_traits ::vertex_descriptor vertex_descriptor; @@ -58,24 +58,24 @@ namespace boost { typedef typename graph_traits::edge_parallel_category edge_parallel_category; void constraints() { - REQUIRE(vertex_descriptor, DefaultConstructible); - REQUIRE(vertex_descriptor, EqualityComparable); - REQUIRE(vertex_descriptor, Assignable); - REQUIRE(edge_descriptor, DefaultConstructible); - REQUIRE(edge_descriptor, EqualityComparable); - REQUIRE(edge_descriptor, Assignable); + BOOST_FUNCTION_REQUIRES(vertex_descriptor, DefaultConstructibleConcept); + BOOST_FUNCTION_REQUIRES(vertex_descriptor, EqualityComparableConcept); + BOOST_FUNCTION_REQUIRES(vertex_descriptor, AssignableConcept); + BOOST_FUNCTION_REQUIRES(edge_descriptor, DefaultConstructibleConcept); + BOOST_FUNCTION_REQUIRES(edge_descriptor, EqualityComparableConcept); + BOOST_FUNCTION_REQUIRES(edge_descriptor, AssignableConcept); } G g; }; template - struct IncidenceGraph_concept + struct IncidenceGraphConcept { typedef typename graph_traits::out_edge_iterator out_edge_iterator; void constraints() { - REQUIRE(G, Graph); - REQUIRE(out_edge_iterator, MultiPassInputIterator); + BOOST_FUNCTION_REQUIRES(G, GraphConcept); + BOOST_FUNCTION_REQUIRES(out_edge_iterator, MultiPassInputIteratorConcept); p = out_edges(v, g); e = *p.first; @@ -95,13 +95,13 @@ namespace boost { }; template - struct BidirectionalGraph_concept + struct BidirectionalGraphConcept { typedef typename graph_traits::in_edge_iterator in_edge_iterator; void constraints() { - REQUIRE(G, IncidenceGraph); - REQUIRE(in_edge_iterator, MultiPassInputIterator); + BOOST_FUNCTION_REQUIRES(G, IncidenceGraphConcept); + BOOST_FUNCTION_REQUIRES(in_edge_iterator, MultiPassInputIteratorConcept); p = in_edges(v, g); e = *p.first; @@ -118,13 +118,13 @@ namespace boost { }; template - struct AdjacencyGraph_concept + struct AdjacencyGraphConcept { typedef typename graph_traits::adjacency_iterator adjacency_iterator; void constraints() { - REQUIRE(G, Graph); - REQUIRE(adjacency_iterator, MultiPassInputIterator); + BOOST_FUNCTION_REQUIRES(G, GraphConcept); + BOOST_FUNCTION_REQUIRES(adjacency_iterator, MultiPassInputIteratorConcept); p = adjacent_vertices(v, g); v = *p.first; @@ -139,14 +139,14 @@ namespace boost { }; template - struct VertexListGraph_concept + struct VertexListGraphConcept { typedef typename graph_traits::vertex_iterator vertex_iterator; typedef typename graph_traits::vertices_size_type vertices_size_type; void constraints() { - REQUIRE(G, AdjacencyGraph); - REQUIRE(G, IncidenceGraph); - REQUIRE(vertex_iterator, MultiPassInputIterator); + BOOST_FUNCTION_REQUIRES(G, AdjacencyGraphConcept); + BOOST_FUNCTION_REQUIRES(G, IncidenceGraphConcept); + BOOST_FUNCTION_REQUIRES(vertex_iterator, MultiPassInputIteratorConcept); p = vertices(g); v = *p.first; @@ -164,13 +164,13 @@ namespace boost { }; template - struct EdgeListGraph_concept + struct EdgeListGraphConcept { typedef typename graph_traits::edge_iterator edge_iterator; typedef typename graph_traits::edges_size_type edges_size_type; void constraints() { - REQUIRE(G, Graph); - REQUIRE(edge_iterator, MultiPassInputIterator); + BOOST_FUNCTION_REQUIRES(G, GraphConcept); + BOOST_FUNCTION_REQUIRES(edge_iterator, MultiPassInputIteratorConcept); p = edges(g); e = *p.first; @@ -193,16 +193,16 @@ namespace boost { }; template - struct VertexAndEdgeListGraph_concept + struct VertexAndEdgeListGraphConcept { void constraints() { - REQUIRE(G, VertexListGraph); - REQUIRE(G, EdgeListGraph); + BOOST_FUNCTION_REQUIRES(G, VertexListGraphConcept); + BOOST_FUNCTION_REQUIRES(G, EdgeListGraphConcept); } }; template - struct MutableGraph_concept + struct MutableGraphConcept { typedef typename graph_traits::edge_descriptor edge_descriptor; void constraints() { @@ -222,11 +222,11 @@ namespace boost { }; template - struct MutablePropertyGraph_concept + struct MutablePropertyGraphConcept { typedef typename graph_traits::edge_descriptor edge_descriptor; void constraints() { - REQUIRE(G, MutableGraph); + BOOST_FUNCTION_REQUIRES(G, MutableGraphConcept); v = add_vertex(vp, g); p = add_edge(u, v, ep, g); } @@ -238,11 +238,11 @@ namespace boost { }; template - struct AdjacencyMatrix_concept + struct AdjacencyMatrixConcept { typedef typename graph_traits::edge_descriptor edge_descriptor; void constraints() { - REQUIRE(G, Graph); + BOOST_FUNCTION_REQUIRES(G, GraphConcept); p = edge(u, v, g); const_constraints(g); @@ -256,14 +256,14 @@ namespace boost { }; template - struct PropertyGraph_concept + struct PropertyGraphConcept { typedef typename property_map::type Map; typedef typename property_map::const_type const_Map; void constraints() { - REQUIRE(G, Graph); - REQUIRE2(Map, X, ReadWritePropertyMap); - REQUIRE2(const_Map, X, ReadablePropertyMap); + BOOST_FUNCTION_REQUIRES(G, GraphConcept); + BOOST_FUNCTION_REQUIRES2(Map, X, ReadWritePropertyMapConcept); + BOOST_FUNCTION_REQUIRES2(const_Map, X, ReadablePropertyMapConcept); Map pmap = get(Property(), g); pval = get(Property(), g, x); @@ -282,7 +282,7 @@ namespace boost { // This needs to move out of the graph library template - struct Buffer_concept + struct BufferConcept { void constraints() { b.push(t); @@ -304,11 +304,11 @@ namespace boost { }; template - struct ColorValue_concept + struct ColorValueConcept { void constraints() { - REQUIRE(C, EqualityComparable); - REQUIRE(C, DefaultConstructible); + BOOST_FUNCTION_REQUIRES(C, EqualityComparableConcept); + BOOST_FUNCTION_REQUIRES(C, DefaultConstructibleConcept); c = white(c); c = gray(c); diff --git a/include/boost/pending/stringtok.hpp b/include/boost/pending/stringtok.hpp index d5b09716..9493a926 100644 --- a/include/boost/pending/stringtok.hpp +++ b/include/boost/pending/stringtok.hpp @@ -62,7 +62,8 @@ namespace { inline bool isws (char c, char const * const wstr) { - return (std::strchr(wstr,c) != NULL); + using namespace std; + return (strchr(wstr,c) != NULL); } }