Boost logo

Boost :

Subject: Re: [boost] [Variant] [BGL] Variant<edge_descriptor, edge_descriptor> is not EqualityComparable
From: Andrew Sutton (andrew.n.sutton_at_[hidden])
Date: 2009-11-12 08:15:10


> // 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
andrew.n.sutton_at_[hidden]


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk