Re: Why this does not compile on g++ but works in Visual C++ 2008
* Jag, on 10.07.2010 01:25:
virtex<T>* add_a_virtex(const virtex<T>& v1) {
//set<virtex<T> > _vertices ;
pair<set<virtex<T> >::iterator,bool> itt = _vertices.insert(v1) ;
/* code removed below */
}
on g++ I get this error.
sgraph.h: In member function `virtex<T>* sgraph<T>::add_a_virtex(const
virtex<T>&)':
sgraph.h:95: error: type/value mismatch at argument 1 in template
parameter list for `template<class _T1, class _T2> struct std::pair'
sgraph.h:95: error: expected a type, got `
std::set<virtex<T>,std::less<virtex<T> >,std::allocator<virtex<T> >
::iterator'
sgraph.h:95: error: invalid type in declaration before '=' token
You're probably missing a 'typename' keyword, like
pair< typename virtex< T > >::iterator, bool > ...
If this is the problem, then T is a template parameter, and the compiler doesn't
absolutely know that virtex<T>::iterator is a type for all choices of T and
needs a little help from you about what it should assume.
This is in the FAQ somewhere, I believe.
Cheers & hth.,
- Alf
--
blog at <url: http://alfps.wordpress.com>