2
0
mirror of https://github.com/boostorg/graph.git synced 2026-01-31 08:12:14 +00:00

Fixed uses of undocumented members of graph types; fixes #1021; fixes #2072

[SVN r57902]
This commit is contained in:
Jeremiah Willcock
2009-11-24 20:17:54 +00:00
parent 09496c3696
commit 2d7c00159e
2 changed files with 45 additions and 9 deletions

View File

@@ -175,10 +175,39 @@ namespace boost {
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 @@ namespace boost {
};
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;

View File

@@ -75,11 +75,6 @@ class reverse_graph {
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 @@ class reverse_graph {
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> >