Re: Why this does not compile on g++ but works in Visual C++ 2008
This is a MIME GnuPG-signed message. If you see this text, it means that
your E-mail or Usenet software does not support MIME signed messages.
The Internet standard for MIME PGP messages, RFC 2015, was published in 1996.
To open this message correctly you will need to install E-mail or Usenet
software that supports modern Internet standards.
--=_mimegpg-commodore.email-scan.com-22469-1278716647-0002
Content-Type: text/plain; format=flowed; charset="US-ASCII"
Content-Disposition: inline
Content-Transfer-Encoding: 7bit
Jag writes:
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
Can some kind soul help me to fix the issue using g++.
There's probably a problem somewhere in either the definition of your virtex
template class, or your _vertices object. However, because you neglected to
post your class definitions, no further help is possible.
The only thing that I can tell you is that the following complete example
which, as far as I can tell using my best guess, is structurally equivalent
with your use case, compiles just fine with g++ 4.4.4:
#include <set>
template<typename T> class virtex {
public:
bool operator<(const virtex<T> &) const;
};
class T {
};
std::set< virtex<T> > _vertices;
void add_a_virtex(const virtex<T> &v1)
{
std::pair<std::set<virtex<T> >::iterator, bool>
itt=_vertices.insert(v1);
}
--=_mimegpg-commodore.email-scan.com-22469-1278716647-0002
Content-Type: application/pgp-signature
Content-Transfer-Encoding: 7bit
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
iEYEABECAAYFAkw3qucACgkQx9p3GYHlUOLr9QCcD3W8YThsiHSuxEyDW421AhvH
ajcAn0vaKv3aa9gQlA/zYwpzgx8RBjeH
=S5/0
-----END PGP SIGNATURE-----
--=_mimegpg-commodore.email-scan.com-22469-1278716647-0002--