|
Boost : |
Subject: Re: [boost] [Variant] [BGL] Variant<edge_descriptor, edge_descriptor> is not EqualityComparable
From: Stefan Strasser (strasser_at_[hidden])
Date: 2009-11-12 10:19:57
Am Thursday 12 November 2009 15:00:09 schrieb Cosimo Calabrese:
> namespace std
> {
> template <typename Graph1, typename Graph2>
> std::ostream& operator<<(std::ostream& os,
> const typename boost::graph_traits<boost::union_graph<Graph1, Graph2>
>
> >::vertex_descriptor& v)
>
> {
> if ( boost::get<WR1<graph_traits<Graph1>::vertex_descriptor> >( &v ) )
> os <<
> boost::get<WR1<graph_traits<Graph1>::vertex_descriptor>
>
> >(v)._data;
>
> else
> os <<
> boost::get<WR2<graph_traits<Graph2>::vertex_descriptor> >(v)._data;
> return os;
> }
> }
the template parameters (Graph1/2) must be deducable from the function
parameter (v).
this is not possible in this example.
consider the following, simpler, case:
template<class T>
struct A{
typedef T type;
};
template<class A_T>
void func(typename A_T::type);
int main(){
int a;
func<A<int> >(); //ok
func(a); //error
}
the compiler has no way of knowing that foo is supposed to be instantiated
with A_T == A, unless you provide an explicit template argument (which you
don't when you call an operator).
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk