Boost logo

Boost :

Subject: Re: [boost] [Variant] [BGL] Variant<edge_descriptor, edge_descriptor> is not EqualityComparable
From: Cosimo Calabrese (cosimo.calabrese_at_[hidden])
Date: 2009-11-17 04:51:30


Andrew Sutton wrote:
>> but this works:
>>
>> namespace std
>>
>> {
>> template <typename T1, typename T2>
>> std::ostream& operator<<(std::ostream& os,
>> const boost::variant<boost::WR1<T1>, boost::WR2<T2> >& v)
>> {
>> if ( boost::get<boost::WR1<T1> >( &v ) )
>> os << boost::get<WR1<T1> >( v )._data;
>> else
>> os << boost::get<WR2<T2> >( v )._data;
>> return os;
>> }
>> }
>>
>> It seems the same case.
>>
>

Thanks Andrew,

> This seems to be a SFINAE problem. Is it possible, that

I've never seen SFINAE before, so I've spent a little on it. It seems
the case in which I've more of one possibility of overload, that can
cause ambiguity. In my case it seems I've no possibility, because there
isn't any compatibility between my operator and the call.

Another real possibility is that I haven't understand SFINAE :)

> graph_traits<union_graph<...>>::vertex_descriptor or edge_descriptor does
> not name an actual type?

If I specify Graph1 and Graph2, the descriptors are defined. I don't
know if it happens in my case. But after reading the Stefan reply, I'm
not sure of it...

> For example, did you misspell the type names inside
> the union_graph class? I've had that problem before (it took an hour to
> figure it out).

Well, I've reported it in the first post. The definition of the
edge_descriptor is:

template <typename Graph1, typename Graph2>
   class union_graph {
   public:

     /* ... */

     typedef boost::variant<
       WR1<typename graph_traits<Graph1>::edge_descriptor>,
       WR2<typename graph_traits<Graph2>::edge_descriptor>
> edge_descriptor;

     /* ... */
};

and the operator definition is:

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 );

So the edge_descriptor definition and the operator arguments type should
correspond. Now I think that the problem is in the call of operator.

>
> There's also a possibility that the compiler is choking on the complexity of
> the parameterization. You are using a slightly dated compiler. Any chance
> you can upgrade?
>

I've tried on MSVS 2008, but the result is the same.

Thank you for help,
Cosimo Calabrese


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