typedef boost::adjacency_list
<boost::vecS, boost::listS, boost::undirectedS, EdgeProperties, VertexProperties, GraphProperties> GraphType ;
template <typename GraphType>
class EdgePredicate
{
public: EdgePredicate () : mpGraph (0) {}
public: EdgePredicate (GraphType& vrGraph) : mpGraph (&vrGraph) {}
public: template <typename EdgeType>
bool operator()(const EdgeType& vEdge) const { return (*mpGraph)[vEdge].mFlag ; }
private: GraphType* mpGraph ;
} ;
template <typename GraphType>
class VertexPredicate
{
public: VertexPredicate () : mpGraph (0) {}
public: VertexPredicate (GraphType& vrGraph) : mpGraph (&vrGraph) {}
public: template <typename VertexType>
bool operator()(const VertexType& vVertex) const { return (*mpGraph)[vVertex].mFlag ; }
private: GraphType* mpGraph ;
} ;
typedef boost::filtered_graph<GraphType, EdgePredicate<GraphType>, VertexPredicate<GraphType> > FilteredGraphType ;
...
void foo ()
{
GraphType graph ;
FilteredGraphType filter (graph, EdgePredicate<GraphType> (graph), VertexPredicate<GraphType> (graph)) ;
graph [boost::graph_bundle].mFlag = true ;
filter [boost::graph_bundle].mFlag ; // ***** Does not compile - see below
...
}
}
...
gcc 4.5.2 issues the following error message
In member function 'typename boost::graph::detail::bundled_result<Graph, Descriptor>::type& boost::filtered_graph<Graph, EdgePredicate, VertexPredicate>::operator[](Descriptor)
[with Descriptor = boost::graph_bundle_t,
Graph = boost::adjacency_list<boost::vecS, boost::listS, boost::undirectedS, TestGraph::EdgeProperties, TestGraph::VertexProperties, TestGraph::GraphProperties>,
EdgePredicate = TestGraph::EdgePredicate<boost::adjacency_list<boost::vecS, boost::listS, boost::undirectedS, TestGraph::EdgeProperties, TestGraph::VertexProperties, TestGraph::GraphProperties> >,
VertexPredicate = TestGraph::VertexPredicate<boost::adjacency_list<boost::vecS, boost::listS, boost::undirectedS, TestGraph::EdgeProperties, TestGraph::VertexProperties, TestGraph::GraphProperties> >,
typename boost::graph::detail::bundled_result<Graph, Descriptor>::type = TestGraph::VertexProperties]':
Visual Studio 2005 issues this error at the same line (see above)
error C2440: 'return' : cannot convert from 'TestGraph::GraphProperties' to 'TestGraph::VertexProperties &'
test-graph-types.h(78) : see reference to function template instantiation 'TestGraph::VertexProperties &boost::filtered_graph<Graph,EdgePredicate,VertexPredicate>::operator []<boost::graph_bundle_t>(Descriptor)' being compiled
with
[
Graph=TestGraph::GraphType,
EdgePredicate=TestGraph::EdgePredicate<TestGraph::GraphType>,
VertexPredicate=TestGraph::VertexPredicate<TestGraph::GraphType>,
Descriptor=boost::graph_bundle_t
]
The error originates in boost filtered_graph.hpp line 201
199 // Bundled properties support
200 template<typename Descriptor>
201 typename graph::detail::bundled_result<Graph, Descriptor>::type&
201 operator[](Descriptor x)
203 { return const_cast<Graph&>(this->m_g)[x]; }
The bug appears to be that using Descriptor = boost::graph_bundle somehow selects the wrong return type for operator[](Descriptor) selecting TestGraph::VertexProperties instead of the expected TestGraph::GraphProperties
This is confirmed by redeclaring the GraphType as
typedef boost::adjacency_list
<boost::vecS, boost::listS, boost::undirectedS, EdgeProperties, VertexProperties, VertexProperties> GraphType ;
i.e. the type for the graph properties happens to be the same as that used for the Vertex properties.
Now it compiles cleanly!!
Can someone help me locate the origin of this problem. I need to patch this quickly :(
It should be noted that there are no problems accessing vertex and edge bundled properties via a filtered_graph - only the graph bundled properties exhibit this issue.
TIA
Tony
_______________________________________________
Boost-users mailing list
Boost...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users
This is probably a bug -- I'll look at it later this afternoon.
-- Jeremiah Willcock
Could you please see if this problem still appears in r69404 of the Boost
trunk (just committed)? If you are using a release, you only need to get
boost/graph/properties.hpp and boost/graph/graph_traits.hpp from the trunk
and overwrite your copies. I believe I have fixed the bug -- your example
from above compiles, at least.
-- Jeremiah Willcock
I adapted this fix approach for my local copy of filtered_graph.hpp like so:
typename Graph::graph_bundled& operator[](graph_bundle_t)
{ return const_cast<Graph&>(this->m_g)[boost::graph_bundle]; }
typename Graph::graph_bundled const& operator[](graph_bundle_t) const
{ return this->m_g[boost::graph_bundle]; }
But your fix is general so the code in reverse_graph.hpp is most likely redundant now - I've chucked my local patch away.
Thanks again, Tony
>
> Hi Jeremiah
>
> ** Confirmed fixed :) Thanks **
>
> You might want to look at reverse_graph.hpp as it worked around the problem using:
>
> typename boost::graph_property_type<base_type>::type& operator[](graph_bundle_t)
> { return get_property(*this); }
> typename boost::graph_property_type<base_type>::type const& operator[](graph_bundle_t) const
> { return get_property(*this); }
>
> I adapted this fix approach for my local copy of filtered_graph.hpp like so:
>
> typename Graph::graph_bundled& operator[](graph_bundle_t)
> { return const_cast<Graph&>(this->m_g)[boost::graph_bundle]; }
> typename Graph::graph_bundled const& operator[](graph_bundle_t) const
> { return this->m_g[boost::graph_bundle]; }
>
> But your fix is general so the code in reverse_graph.hpp is most likely redundant now - I've chucked my local patch away.
Thanks for catching that -- I removed the workaround from
reverse_graph.hpp and it still worked.