|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r57902 - trunk/boost/graph
From: jewillco_at_[hidden]
Date: 2009-11-24 15:17:55
Author: jewillco
Date: 2009-11-24 15:17:54 EST (Tue, 24 Nov 2009)
New Revision: 57902
URL: http://svn.boost.org/trac/boost/changeset/57902
Log:
Fixed uses of undocumented members of graph types; fixes #1021; fixes #2072
Text files modified:
trunk/boost/graph/properties.hpp | 37 +++++++++++++++++++++++++++++++++----
trunk/boost/graph/reverse_graph.hpp | 17 ++++++++++++-----
2 files changed, 45 insertions(+), 9 deletions(-)
Modified: trunk/boost/graph/properties.hpp
==============================================================================
--- trunk/boost/graph/properties.hpp (original)
+++ trunk/boost/graph/properties.hpp 2009-11-24 15:17:54 EST (Tue, 24 Nov 2009)
@@ -175,10 +175,39 @@
namespace detail {
+ template <typename A> struct return_void {typedef void type;};
+
+ template <typename Graph, typename Enable = void>
+ struct graph_tag_or_void {
+ typedef void type;
+ };
+
+ template <typename Graph>
+ struct graph_tag_or_void<Graph, typename return_void<typename Graph::graph_tag>::type> {
+ typedef typename Graph::graph_tag type;
+ };
+
+ // This code is from boost/thread/locks.hpp (with the member name changed
+ // and changed to look for a member type) and should be factored out into a
+ // separate library (type_traits?).
+ template<typename T>
+ struct has_member_graph_tag {
+ typedef char true_type;
+ struct false_type {
+ true_type dummy[2];
+ };
+
+ template<typename U>
+ static true_type has_member(U*,typename U::graph_tag* = 0);
+ static false_type has_member(void*, ...);
+
+ BOOST_STATIC_CONSTANT(bool, value=sizeof(has_member_graph_tag<T>::has_member((T*)NULL))==sizeof(true_type));
+ };
+
template <class Graph, class PropertyTag>
struct edge_property_map {
- typedef typename Graph::edge_property_type Property;
- typedef typename Graph::graph_tag graph_tag;
+ typedef typename edge_property_type<Graph>::type Property;
+ typedef typename graph_tag_or_void<Graph>::type graph_tag;
typedef typename edge_property_selector<graph_tag>::type Selector;
typedef typename Selector::template bind_<Graph,Property,PropertyTag>
Bind;
@@ -187,8 +216,8 @@
};
template <class Graph, class PropertyTag>
class vertex_property_map {
- typedef typename Graph::vertex_property_type Property;
- typedef typename Graph::graph_tag graph_tag;
+ typedef typename vertex_property_type<Graph>::type Property;
+ typedef typename graph_tag_or_void<Graph>::type graph_tag;
typedef typename vertex_property_selector<graph_tag>::type Selector;
typedef typename Selector::template bind_<Graph,Property,PropertyTag>
Bind;
Modified: trunk/boost/graph/reverse_graph.hpp
==============================================================================
--- trunk/boost/graph/reverse_graph.hpp (original)
+++ trunk/boost/graph/reverse_graph.hpp 2009-11-24 15:17:54 EST (Tue, 24 Nov 2009)
@@ -75,11 +75,6 @@
typedef typename Traits::vertices_size_type vertices_size_type;
typedef typename Traits::edges_size_type edges_size_type;
- // More typedefs used by detail::edge_property_map, vertex_property_map
- typedef typename boost::edge_property_type<BidirectionalGraph>::type
- edge_property_type;
- typedef typename boost::vertex_property_type<BidirectionalGraph>::type
- vertex_property_type;
typedef reverse_graph_tag graph_tag;
#ifndef BOOST_GRAPH_NO_BUNDLED_PROPERTIES
@@ -105,6 +100,18 @@
GraphRef m_g;
};
+
+// These are separate so they are not instantiated unless used (see bug 1021)
+template <class BidirectionalGraph, class GraphRef>
+struct vertex_property_type<reverse_graph<BidirectionalGraph, GraphRef> > {
+ typedef typename boost::vertex_property_type<BidirectionalGraph>::type type;
+};
+
+template <class BidirectionalGraph, class GraphRef>
+struct edge_property_type<reverse_graph<BidirectionalGraph, GraphRef> > {
+ typedef typename boost::edge_property_type<BidirectionalGraph>::type type;
+};
+
#ifndef BOOST_GRAPH_NO_BUNDLED_PROPERTIES
template<typename Graph, typename GraphRef>
struct vertex_bundle_type<reverse_graph<Graph, GraphRef> >
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk