By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,906 Members | 1,387 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,906 IT Pros & Developers. It's quick & easy.

anon enums porting problem

P: n/a

the following code fragment doesn't compile:

#include <iostream>

template<class T, std::size_t Sz>
class Vector
typedef const T* const_iterator;


enum { Size = Sz };
static const std::size_t Size = Sz;

template <class T2> Vector& M_add_eq(const Vector<T2, Size>&);

template<class T1, std::size_t Sz>
template <class T2>
inline Vector<T1, Sz>&
Vector<T1, Sz>::M_add_eq (const Vector<T2, Size>& rhs) {
// make something
return *this;

/usr/local/bin/g++ -V3.3 -O -DUSE_ANONYMOUS_ENUM -c Fehler: prototype for `Vector<T, Sz>& Vector<T,
Sz>::M_add_eq(const Vector<T2, Vector<T, Sz>::Size>&)' does not
match any in
class `Vector<T, Sz>' Fehler: candidate is: template<class T, unsigned int Sz>
template<class T2> Vector& Vector::M_add_eq(const Vector<T2, Size>&) Fehler: template definition of non-template `Vector<T,
Vector<T, Sz>::M_add_eq(const Vector<T2, Vector<T, Sz>::Size>&)'

/usr/local/bin/g++ -V4.0.2 -O -c
/usr/local/bin/g++ -V4.0.2 -O -DUSE_ANONYMOUS_ENUM -c

I'm asontished, that g++ 3.x doesn't compiler it, gcc4 and icc does.
Normally I would expected an anonymous enum error by gcc4. I've seen
this for some other compile tests some days ago, but not for these
example above. What's going on here? Some rules here? How can I get
these working for older compilers?

Thanks and regards

Nov 8 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.