
Andrew Sutton wrote:
// EqualityComparable concept, requested by IncidenceGraph concept template <typename Graph1, typename Graph2> inline bool operator!=( const typename boost::graph_traits< boost::union_graph<Graph1, Graph2> >::edge_descriptor& left, const typename boost::graph_traits< boost::union_graph<Graph1, Graph2> >::edge_descriptor& right ) { return !( left == right ); }
UG ug( g1, g2 );
graph_traits<UG>::edge_descriptor e1; graph_traits<UG>::edge_descriptor e2;
tie( e1, existence ) = edge( v1, v2, g ); tie( e2, existence ) = edge( v1, v2, g );
e1 != e2; }
I looks like the inequality operator is provided in terms of edge descriptors, but you're actually comparing variants. You may be able to get away with writing something like:
template <typename G1, typename G2> bool operator!=( typename graph_traits<union_graph<G1, G2>>::edge_descriptor left, typename graph_traits<union_graph<G1, G2>>::edge_descriptor right) { ... }
That should generate an inequality operator over variants, but prevent the template from becoming overly general, since its explicitly "specialized" for your union_graph.
Maybe?
Andrew Sutton
I'm in agreement with you, but that code doesn't work. I don't know why, I've tried it yesterday. This is my version. I've written it in the global namespace, not in boost namespace: template <typename G1, typename G2> bool operator!=( typename boost::graph_traits<boost::union_graph<G1, G2>
::edge_descriptor left, typename boost::graph_traits<boost::union_graph<G1, G2> >::edge_descriptor right ) { return !( left == right ); }
Instead it works the follow, more general: template <typename T0_, typename T1> inline bool operator!=( const boost::variant<T0_, T1>& left, const boost::variant<T0_, T1>& right ) { return !( left == right ); } I've written it in the same position of the first version, but it provides the operator!=() for all the variant specialization... What do you think about? Cheers, Cosimo Calabrese.