diff --git a/examples/adjacency_list.cpp b/examples/adjacency_list.cpp index de244b80..ad4db12f 100644 --- a/examples/adjacency_list.cpp +++ b/examples/adjacency_list.cpp @@ -51,7 +51,7 @@ */ -int main(int argc, char* argv[]) +int main(int , char* []) { using namespace boost; using namespace std; diff --git a/examples/bfs.cpp b/examples/bfs.cpp index 4b400683..596a8815 100644 --- a/examples/bfs.cpp +++ b/examples/bfs.cpp @@ -104,7 +104,7 @@ copy_graph(NewGraph& g, Tag) { return graph_copier(g); } -int main(int argc, char* argv[]) +int main(int , char* []) { typedef boost::adjacency_list< boost::mapS, boost::vecS, boost::bidirectionalS, diff --git a/examples/bfs_basics.cpp b/examples/bfs_basics.cpp index ed8f6d68..2f34341b 100644 --- a/examples/bfs_basics.cpp +++ b/examples/bfs_basics.cpp @@ -58,7 +58,7 @@ using namespace std; using namespace boost; -int main(int argc, char* argv[]) +int main(int, char*[]) { // Select the graph type we wish to use typedef adjacency_list Graph; diff --git a/examples/components_on_edgelist.cpp b/examples/components_on_edgelist.cpp index c1ec7cad..7274c4e7 100644 --- a/examples/components_on_edgelist.cpp +++ b/examples/components_on_edgelist.cpp @@ -68,7 +68,7 @@ using namespace std; using boost::tie; -int main(int argc, char* argv[]) +int main(int , char* []) { using namespace boost; typedef int Index; // ID of a Vertex diff --git a/examples/concept_checks.cpp b/examples/concept_checks.cpp index 9b7c3d96..cb505975 100644 --- a/examples/concept_checks.cpp +++ b/examples/concept_checks.cpp @@ -57,6 +57,7 @@ main(int,char*[]) typedef boost::graph_traits::vertex_descriptor Vertex; REQUIRE2(IndexMap, Vertex, ReadablePropertyMap); } +#if 0 { typedef adjacency_list, @@ -107,5 +108,6 @@ main(int,char*[]) typedef Graph* Graph; REQUIRE(Graph, VertexListGraph); } +#endif return 0; } diff --git a/examples/connected_components.cpp b/examples/connected_components.cpp index eb4c44c1..e5d97354 100644 --- a/examples/connected_components.cpp +++ b/examples/connected_components.cpp @@ -64,7 +64,7 @@ using namespace std; -int main(int argc, char* argv[]) +int main(int , char* []) { // First example: the connected components of an undirected graph using namespace boost; diff --git a/examples/cuthill_mckee_ordering.cpp b/examples/cuthill_mckee_ordering.cpp index 3ca01f3f..cc6ee2dd 100644 --- a/examples/cuthill_mckee_ordering.cpp +++ b/examples/cuthill_mckee_ordering.cpp @@ -40,7 +40,7 @@ Reverse Cuthill-McKee ordering: //choose vertex 9 0 8 5 7 3 6 4 2 1 9 */ -int main(int argc, char* argv[]) +int main(int , char* []) { using namespace boost; using namespace std; diff --git a/examples/dave.cpp b/examples/dave.cpp index 9015a192..7db4348f 100644 --- a/examples/dave.cpp +++ b/examples/dave.cpp @@ -166,7 +166,7 @@ void print(Graph& G, Name name) int -main(int argc, char* argv[]) +main(int , char* []) { // Name and ID numbers for the vertices char name[] = "abcdefg"; diff --git a/examples/dfs.cpp b/examples/dfs.cpp index 316ba6fc..26565297 100644 --- a/examples/dfs.cpp +++ b/examples/dfs.cpp @@ -92,7 +92,7 @@ categorize_edges(const VisitorList& v) { } int -main(int argc, char* argv[]) +main(int , char* []) { using namespace boost; diff --git a/examples/dfs_basics.cpp b/examples/dfs_basics.cpp index 54b3a518..9ea7c08c 100644 --- a/examples/dfs_basics.cpp +++ b/examples/dfs_basics.cpp @@ -66,7 +66,7 @@ using namespace boost; -int main(int argc, char* argv[]) +int main(int, char*[]) { // Select the graph type we wish to use typedef adjacency_list Graph; diff --git a/examples/dfs_parenthesis.cpp b/examples/dfs_parenthesis.cpp index 184630ba..e57f316b 100644 --- a/examples/dfs_parenthesis.cpp +++ b/examples/dfs_parenthesis.cpp @@ -59,7 +59,7 @@ struct close_paren : public base_visitor { int -main(int argc, char* argv[]) +main(int, char*[]) { using namespace boost; diff --git a/examples/dijkstra.cpp b/examples/dijkstra.cpp index e30377eb..c0707489 100644 --- a/examples/dijkstra.cpp +++ b/examples/dijkstra.cpp @@ -48,7 +48,7 @@ */ int -main(int argc, char* argv[]) +main(int , char* []) { using namespace boost; diff --git a/examples/dynamic_components.cpp b/examples/dynamic_components.cpp index 24385e99..6af99db8 100644 --- a/examples/dynamic_components.cpp +++ b/examples/dynamic_components.cpp @@ -61,7 +61,7 @@ using namespace std; -int main(int argc, char* argv[]) +int main(int , char* []) { using namespace boost; typedef adjacency_list Graph; diff --git a/examples/edge_property.cpp b/examples/edge_property.cpp index 92c9adbb..9d4f06b9 100644 --- a/examples/edge_property.cpp +++ b/examples/edge_property.cpp @@ -119,7 +119,7 @@ void print_network(Graph& G, Capacity capacity, Flow flow) } -int main(int argc, char* argv[]) +int main(int , char* []) { typedef property Cap; typedef property Flow; diff --git a/examples/exterior_properties.cpp b/examples/exterior_properties.cpp index c90750c1..8f4e9d42 100644 --- a/examples/exterior_properties.cpp +++ b/examples/exterior_properties.cpp @@ -79,7 +79,7 @@ void print_network(Graph& G, Capacity capacity, Flow flow) } -int main(int argc, char* argv[]) { +int main(int , char* []) { typedef boost::adjacency_list #include #include #include diff --git a/examples/kruskal.cpp b/examples/kruskal.cpp index 12c4cea8..6c965366 100644 --- a/examples/kruskal.cpp +++ b/examples/kruskal.cpp @@ -41,7 +41,7 @@ */ -int main(int argc, char* argv[]) +int main(int , char* []) { using namespace boost; using namespace std; diff --git a/examples/prim.cpp b/examples/prim.cpp index 3b782d73..63c6182c 100644 --- a/examples/prim.cpp +++ b/examples/prim.cpp @@ -43,7 +43,7 @@ // parent[i] = c // -int main(int argc, char* argv[]) +int main(int , char* []) { using namespace boost; typedef adjacency_list Pair; */ int -main(int argc, char* argv[]) +main(int , char* []) { //begin using namespace boost; diff --git a/examples/visitor.cpp b/examples/visitor.cpp index 2c18dfc4..12860e7c 100644 --- a/examples/visitor.cpp +++ b/examples/visitor.cpp @@ -79,7 +79,7 @@ edge_printer print_edge(std::string type, Tag) { } int -main(int argc, char* argv[]) +main(int, char*[]) { using namespace boost; diff --git a/include/boost/graph/adjacency_list.hpp b/include/boost/graph/adjacency_list.hpp index 7f14874a..2a235072 100644 --- a/include/boost/graph/adjacency_list.hpp +++ b/include/boost/graph/adjacency_list.hpp @@ -225,11 +225,13 @@ namespace boost { namespace detail { template struct is_random_access { - enum { value = false}; + enum { value = false}; + typedef false_type type; }; template <> struct is_random_access { enum { value = true }; + typedef true_type type; }; } // namespace detail @@ -238,9 +240,20 @@ namespace boost { //=========================================================================== // Selectors for the Directed template parameter of adjacency_list. - struct directedS { enum { is_directed = true, is_bidir = false }; }; - struct undirectedS { enum { is_directed = false, is_bidir = false }; }; - struct bidirectionalS { enum { is_directed = true, is_bidir = true }; }; + struct directedS { enum { is_directed = true, is_bidir = false }; + typedef true_type is_directed_t; + typedef false_type is_bidir_t; + }; + struct undirectedS { + enum { is_directed = false, is_bidir = false }; + typedef false_type is_directed_t; + typedef false_type is_bidir_t; + }; + struct bidirectionalS { + enum { is_directed = true, is_bidir = true }; + typedef true_type is_directed_t; + typedef true_type is_bidir_t; + }; //=========================================================================== // The adjacency_list_traits class, which provides a way to access @@ -254,11 +267,14 @@ namespace boost { class DirectedS = directedS> struct adjacency_list_traits { - enum { is_rand_access = detail::is_random_access::value }; + typedef typename detail::is_random_access::type + is_rand_access; + typedef typename DirectedS::is_bidir_t is_bidir; + typedef typename DirectedS::is_directed_t is_directed; - typedef typename boost::ct_if::type >::type directed_category; @@ -267,9 +283,8 @@ namespace boost { edge_parallel_category; typedef void* vertex_ptr; - typedef typename boost::ct_if::type vertex_descriptor; - typedef detail::edge_desc_impl edge_descriptor; }; diff --git a/include/boost/graph/connected_components.hpp b/include/boost/graph/connected_components.hpp index 20d2fb36..eb09d299 100644 --- a/include/boost/graph/connected_components.hpp +++ b/include/boost/graph/connected_components.hpp @@ -133,7 +133,8 @@ namespace boost { FinishTime f, Color color, directed_tag) { typedef typename graph_traits::vertex_descriptor Vertex; - typename property_traits::value_type cc; + typename property_traits::value_type + cc = get(color, *vertices(G).first); int time = 0; depth_first_search(G, record_times(d, f, time, v), color); diff --git a/include/boost/graph/depth_first_search.hpp b/include/boost/graph/depth_first_search.hpp index 0eff0283..d9849662 100644 --- a/include/boost/graph/depth_first_search.hpp +++ b/include/boost/graph/depth_first_search.hpp @@ -70,7 +70,8 @@ namespace boost { depth_first_search(VertexListGraph& g, DFSVisitor vis, ColorMap color) { REQUIRE2(DFSVisitor, VertexListGraph, DFSVisitor); - typename property_traits::value_type c; + typename property_traits::value_type + c = get(color, *vertices(g).first); // value of c not used, just type typename graph_traits::vertex_iterator ui, ui_end; for (tie(ui, ui_end) = vertices(g); ui != ui_end; ++ui) { diff --git a/include/boost/graph/detail/adjacency_list.hpp b/include/boost/graph/detail/adjacency_list.hpp index a1cbd58b..08c8b7bb 100644 --- a/include/boost/graph/detail/adjacency_list.hpp +++ b/include/boost/graph/detail/adjacency_list.hpp @@ -154,9 +154,15 @@ namespace boost { #endif template - struct has_property { enum { value = true }; }; + struct has_property { + enum { value = true }; + typedef true_type type; + }; template <> - struct has_property { enum { value = false }; }; + struct has_property { + enum { value = false }; + typedef false_type type; + }; //========================================================================= @@ -1026,6 +1032,7 @@ namespace boost { g.out_edge_list(u).clear(); g.in_edge_list(u).clear(); } + // O(1) for allow_parallel_edge_tag // O(log(E/V)) for disallow_parallel_edge_tag template @@ -1055,6 +1062,7 @@ namespace boost { return std::make_pair(edge_descriptor(u,v), false); } } + template inline std::pair add_edge(typename Config::vertex_descriptor u, @@ -1141,7 +1149,7 @@ namespace boost { inline std::pair add_edge(typename Config::vertex_descriptor u, typename Config::vertex_descriptor v, - const no_property&, + const no_property&, bidirectional_graph_helper_without_property& g_) { return add_edge(u, v, g_); @@ -1239,11 +1247,14 @@ namespace boost { // protected: + // The edge_dispatch() functions should be static, but + // Borland gets confused about constness. + // O(E/V) - static inline std::pair + inline std::pair edge_dispatch(const AdjList& g, vertex_descriptor u, vertex_descriptor v, - boost::allow_parallel_edge_tag) + boost::allow_parallel_edge_tag) const { bool found; const typename Config::OutEdgeList& el = g.out_edge_list(u); @@ -1257,10 +1268,10 @@ namespace boost { return std::make_pair(edge_descriptor(u, v), false); } // O(log(E/V)) - static inline std::pair + inline std::pair edge_dispatch(const AdjList& g, vertex_descriptor u, vertex_descriptor v, - boost::disallow_parallel_edge_tag) + boost::disallow_parallel_edge_tag) const { bool found; typename Config::OutEdgeList::const_iterator @@ -1742,11 +1753,11 @@ namespace boost { add_edge(typename Config::vertex_descriptor u, typename Config::vertex_descriptor v, const typename Config::edge_property_type& p, - vec_adj_list_impl& g_) + vec_adj_list_impl& g_) { typename Config::vertex_descriptor x = std::max(u, v); if (x >= num_vertices(g_)) - g_.m_vertices.resize(x + 1); + g_.m_vertices.resize(x + 1); adj_list_helper& g = g_; return add_edge(u, v, p, g); } @@ -1754,7 +1765,7 @@ namespace boost { inline std::pair add_edge(typename Config::vertex_descriptor u, typename Config::vertex_descriptor v, - vec_adj_list_impl& g_) + vec_adj_list_impl& g_) { typename Config::edge_property_type p; return add_edge(u, v, p, g_); @@ -1803,10 +1814,9 @@ namespace boost { for (vertex_descriptor v = 0; v < V; ++v) reindex_edge_list(g.out_edge_list(v), u, edge_parallel_category()); - - typename Graph::EdgeContainer::iterator - ei = g.m_edges.begin(), - ei_end = g.m_edges.end(); + typedef typename Graph::EdgeContainer Container; + typedef typename Container::iterator Iter; + Iter ei = g.m_edges.begin(), ei_end = g.m_edges.end(); for (; ei != ei_end; ++ei) { if (ei->m_source > u) --ei->m_source; @@ -1869,10 +1879,11 @@ namespace boost { class GraphProperty> struct adjacency_list_generator { - enum { is_rand_access = detail::is_random_access::value, - has_edge_property = has_property::value, - Directed = DirectedS::is_directed, - Bidirectional = DirectedS::is_bidir }; + typedef typename detail::is_random_access::type + is_rand_access; + typedef typename has_property::type has_edge_property; + typedef typename DirectedS::is_directed_t DirectedT; + typedef typename DirectedS::is_bidir_t BidirectionalT; struct config { @@ -1896,7 +1907,7 @@ namespace boost { typedef typename container_gen::type SeqVertexList; typedef boost::integer_range RandVertexList; - typedef typename boost::ct_if::type VertexList; typedef typename VertexList::iterator vertex_iterator; @@ -1911,41 +1922,42 @@ namespace boost { // need to reorganize this to avoid instantiating stuff // that doesn't get used -JGS - typedef typename boost::ct_if< Directed, - typename boost::ct_if< Bidirectional && has_edge_property, + typedef typename boost::ct_if_t::type, BidirEdgeList, no_property >::type, - typename boost::ct_if< has_edge_property, + typename boost::ct_if_t::type >::type EdgeContainer; - typedef typename boost::ct_if< Directed, - typename boost::ct_if< Bidirectional && has_edge_property, + typedef typename boost::ct_if_t::type, typename BidirEdgeList::size_type, std::size_t >::type, - typename boost::ct_if< has_edge_property, + typename boost::ct_if_t::type >::type edges_size_type; - typedef typename boost::ct_if< Directed, - typename boost::ct_if< Bidirectional && has_edge_property, + typedef typename boost::ct_if_t< DirectedT, + typename boost::ct_if_t::type, typename BidirEdgeList::iterator, typename BidirEdgeList::iterator // bogus, not used >::type, - typename boost::ct_if< has_edge_property, + typename boost::ct_if_t::type >::type EdgeIter; - typedef typename boost::ct_if< Directed && !Bidirectional, - typename boost::ct_if< has_edge_property, + typedef typename ct_and::type>::type on_edge_storage; + typedef typename boost::ct_if_t, stored_edge >::type, @@ -2022,7 +2034,7 @@ namespace boost { typedef adj_list_edge_iterator DirectedEdgeIter; - typedef typename boost::ct_if< Directed, + typedef typename boost::ct_if_t::type edge_iterator; // stored_vertex and StoredVertexList @@ -2048,32 +2060,34 @@ namespace boost { InEdgeList m_in_edges; VertexProperty m_property; }; - typedef typename boost::ct_if< is_rand_access, - typename boost::ct_if< Bidirectional, + typedef typename boost::ct_if_t::type, - typename boost::ct_if< Bidirectional, + typename boost::ct_if_t::type >::type StoredVertex; struct stored_vertex : public StoredVertex { }; typedef typename container_gen::type RandStoredVertexList; - typedef typename boost::ct_if< is_rand_access, + typedef typename boost::ct_if_t< is_rand_access, RandStoredVertexList, SeqStoredVertexList>::type StoredVertexList; - }; + }; // end of config - typedef typename boost::ct_if< Bidirectional, - typename boost::ct_if< has_edge_property, + + + typedef typename boost::ct_if_t, bidirectional_graph_helper_without_property >::type, - typename boost::ct_if< Directed, + typename boost::ct_if_t, undirected_graph_helper >::type >::type DirectedHelper; - typedef typename boost::ct_if< is_rand_access, + typedef typename boost::ct_if_t, adj_list_impl >::type type; diff --git a/include/boost/graph/detail/array_binary_tree.hpp b/include/boost/graph/detail/array_binary_tree.hpp index 7fd7bf44..e2a13297 100644 --- a/include/boost/graph/detail/array_binary_tree.hpp +++ b/include/boost/graph/detail/array_binary_tree.hpp @@ -43,6 +43,7 @@ namespace adstl { #endif class array_binary_tree_node { public: + typedef array_binary_tree_node ArrayBinaryTreeNode; typedef RandomAccessIterator rep_iterator; #if !defined BOOST_NO_STD_ITERATOR_TRAITS typedef typename std::iterator_traits::difference_type @@ -57,8 +58,8 @@ public: struct children_type { struct iterator - : boost::iterator + : boost::iterator { // replace with iterator_adaptor implementation -JGS inline iterator() : i(0), n(0) { } @@ -73,7 +74,8 @@ public: size_type ii, size_type nn, const ID& _id) : r(rr), i(ii), n(nn), id(_id) { } - inline array_binary_tree_node operator*() { return array_binary_tree_node(r, i, n, id); } + inline array_binary_tree_node operator*() { + return ArrayBinaryTreeNode(r, i, n, id); } inline iterator& operator++() { ++i; return *this; } inline iterator operator++(int) { iterator t = *this; ++(*this); return t; } @@ -116,7 +118,7 @@ public: inline array_binary_tree_node() : i(0), n(0) { } inline array_binary_tree_node(const array_binary_tree_node& x) : r(x.r), i(x.i), n(x.n), id(x.id) { } - inline array_binary_tree_node& operator=(const array_binary_tree_node& x) { + inline ArrayBinaryTreeNode& operator=(const ArrayBinaryTreeNode& x) { r = x.r; i = x.i; n = x.n; @@ -125,16 +127,18 @@ public: return *this; } inline array_binary_tree_node(rep_iterator start, - rep_iterator end, - rep_iterator pos, const ID& _id) + rep_iterator end, + rep_iterator pos, const ID& _id) : r(start), i(pos - start), n(end - start), id(_id) { } inline array_binary_tree_node(rep_iterator rr, - size_type ii, - size_type nn, const ID& _id) + size_type ii, + size_type nn, const ID& _id) : r(rr), i(ii), n(nn), id(_id) { } inline value_type& value() { return *(r + i); } inline const value_type& value() const { return *(r + i); } - inline array_binary_tree_node parent() const { return array_binary_tree_node(r, (i - 1) / 2, n, id); } + inline ArrayBinaryTreeNode parent() const { + return ArrayBinaryTreeNode(r, (i - 1) / 2, n, id); + } inline bool has_parent() const { return i != 0; } inline children_type children() { return children_type(r, i, n, id); } /* @@ -146,7 +150,7 @@ public: } */ template - inline void swap(array_binary_tree_node x, ExternalData& edata ) { + inline void swap(ArrayBinaryTreeNode x, ExternalData& edata ) { value_type tmp = x.value(); /*swap external data*/ diff --git a/include/boost/graph/edge_list.hpp b/include/boost/graph/edge_list.hpp index b8c9308c..92735a01 100644 --- a/include/boost/graph/edge_list.hpp +++ b/include/boost/graph/edge_list.hpp @@ -33,125 +33,148 @@ #include #include -#ifndef __GNUC__ namespace boost { -#endif -// -// The edge_list class is an EdgeListGraph module that is constructed -// from a pair of iterators whose value type is a pair of vertex -// descriptors. -// -// For example: -// -// typedef std::pair E; -// list elist; -// ... -// typedef edge_list::iterator> Graph; -// Graph g(elist.begin(), elist.end()); -// -// If the iterators are random access, then Graph::edge_descriptor -// is of Integral type, otherwise it is a struct, though it is -// convertible to an Integral type. -// + // + // The edge_list class is an EdgeListGraph module that is constructed + // from a pair of iterators whose value type is a pair of vertex + // descriptors. + // + // For example: + // + // typedef std::pair E; + // list elist; + // ... + // typedef edge_list::iterator> Graph; + // Graph g(elist.begin(), elist.end()); + // + // If the iterators are random access, then Graph::edge_descriptor + // is of Integral type, otherwise it is a struct, though it is + // convertible to an Integral type. + // -// The implementation class for edge_list. -template -class edge_list_impl -{ -public: - typedef D Eid; - typedef T Vpair; - typedef typename Vpair::first_type V; - typedef V vertex_descriptor; - - struct edge_descriptor + // The implementation class for edge_list. + template + class edge_list_impl { - edge_descriptor() { } - edge_descriptor(EdgeIter p, Eid id) : _ptr(p), _id(id) { } - operator Eid() { return _id; } - EdgeIter _ptr; - Eid _id; + public: + typedef D Eid; + typedef T Vpair; + typedef typename Vpair::first_type V; + typedef V vertex_descriptor; + + struct edge_descriptor + { + edge_descriptor() { } + edge_descriptor(EdgeIter p, Eid id) : _ptr(p), _id(id) { } + operator Eid() { return _id; } + EdgeIter _ptr; + Eid _id; + }; + typedef edge_descriptor E; + + struct edge_iterator + { + typedef edge_iterator self; + typedef E value_type; + typedef E& reference; + typedef E* pointer; + typedef std::ptrdiff_t difference_type; + typedef std::input_iterator_tag iterator_category; + edge_iterator() { } + edge_iterator(EdgeIter iter) : _iter(iter), _i(0) { } + E operator*() { return E(_iter, _i); } + self& operator++() { ++_iter; ++_i; return *this; } + self operator++(int) { self t = *this; ++(*this); return t; } + bool operator==(const self& x) { return _iter == x._iter; } + bool operator!=(const self& x) { return _iter != x._iter; } + EdgeIter _iter; + Eid _i; + }; + typedef void out_edge_iterator; + typedef void in_edge_iterator; + typedef void adjacency_iterator; + typedef void vertex_iterator; }; - typedef edge_descriptor E; - struct edge_iterator - { - typedef edge_iterator self; - typedef E value_type; - typedef E& reference; - typedef E* pointer; - typedef std::ptrdiff_t difference_type; - typedef std::input_iterator_tag iterator_category; - edge_iterator() { } - edge_iterator(EdgeIter iter) : _iter(iter), _i(0) { } - E operator*() { return E(_iter, _i); } - self& operator++() { ++_iter; ++_i; return *this; } - self operator++(int) { self t = *this; ++(*this); return t; } - bool operator==(const self& x) { return _iter == x._iter; } - bool operator!=(const self& x) { return _iter != x._iter; } - EdgeIter _iter; - Eid _i; - }; - typedef void out_edge_iterator; - typedef void in_edge_iterator; - typedef void adjacency_iterator; - typedef void vertex_iterator; - - typedef std::pair EdgesRet; - - friend EdgesRet edges(const G& g) { - return EdgesRet(edge_iterator(g._first), edge_iterator(g._last)); + template + std::pair::edge_iterator, + typename edge_list_impl::edge_iterator> + edges(const edge_list_impl& g_) { + const G& g = static_cast(g_); + typedef typename edge_list_impl::edge_iterator edge_iterator; + return std::make_pair(edge_iterator(g._first), edge_iterator(g._last)); } - friend V source(E e, const G&) { + template + typename edge_list_impl::vertex_descriptor + source(typename edge_list_impl::edge_descriptor e, + const edge_list_impl&) { return (*e._ptr).first; } - friend V target(E e, const G&) { + template + typename edge_list_impl::vertex_descriptor + target(typename edge_list_impl::edge_descriptor e, + const edge_list_impl&) { return (*e._ptr).second; } -}; -// A specialized implementation for when the iterators are random access. -template -class edge_list_impl_ra -{ -public: - typedef D E; - typedef T Vpair; - typedef typename Vpair::first_type V; - - typedef E edge_descriptor; - typedef V vertex_descriptor; - typedef typename boost::integer_range::iterator edge_iterator; - typedef void out_edge_iterator; - typedef void in_edge_iterator; - typedef void adjacency_iterator; - typedef void vertex_iterator; - - typedef std::pair EdgesRet; + // A specialized implementation for when the iterators are random access. - friend EdgesRet edges(const G& g) { - return EdgesRet(edge_iterator(0), edge_iterator(g._last - g._first)); + template + class edge_list_impl_ra + { + public: + typedef D E; + typedef T Vpair; + typedef typename Vpair::first_type V; + + typedef E edge_descriptor; + typedef V vertex_descriptor; + typedef typename boost::integer_range::iterator edge_iterator; + typedef void out_edge_iterator; + typedef void in_edge_iterator; + typedef void adjacency_iterator; + typedef void vertex_iterator; + }; + + template + std::pair::edge_iterator, + typename edge_list_impl_ra::edge_iterator> + edges(const edge_list_impl_ra& g_) + { + const G& g = static_cast(g_); + typedef typename edge_list_impl_ra::edge_iterator edge_iterator; + return std::make_pair(edge_iterator(0), edge_iterator(g._last - g._first)); } - friend V source(E e, const G& g) { + template + typename edge_list_impl_ra::vertex_descriptor + source(typename edge_list_impl_ra::edge_descriptor e, + const edge_list_impl_ra& g_) + { + const G& g = static_cast(g_); return g._first[e].first; } - friend V target(E e, const G& g) { + template + typename edge_list_impl_ra::vertex_descriptor + target(typename edge_list_impl_ra::edge_descriptor e, + const edge_list_impl_ra& g_) + { + const G& g = static_cast(g_); return g._first[e].second; } -}; - -#ifdef __GNUC__ -namespace boost { -#endif // Some helper classes for determining if the iterators are random access template - struct is_random { enum { RET = false }; }; + struct is_random { + enum { RET = false }; + typedef false_type type; + }; template <> - struct is_random { enum { RET = true }; }; + struct is_random { + enum { RET = true }; typedef true_type type; + }; // The edge_list class conditionally inherits from one of the // above two classes. @@ -159,11 +182,12 @@ namespace boost { #if !defined BOOST_NO_STD_ITERATOR_TRAITS template ::value_type, - class D = typename std::iterator_traits::difference_type > + class D = typename std::iterator_traits::difference_type> class edge_list - : public ct_if< is_random::iterator_category>::RET, - edge_list_impl_ra< edge_list, EdgeIter, T, D >, - edge_list_impl< edge_list, EdgeIter, T, D > + : public ct_if_t< typename is_random< + typename std::iterator_traits::iterator_category>::type, + edge_list_impl_ra< edge_list, EdgeIter,T,D>, + edge_list_impl< edge_list, EdgeIter,T,D> >::type #else template