Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > anon enums porting problem

Reply
Thread Tools

anon enums porting problem

 
 
Olaf Petzold
Guest
Posts: n/a
 
      11-08-2005
Hi,

the following code fragment doesn't compile:

----8<------
#include <iostream>



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

public:

#if defined(USE_ANONYMOUS_ENUM)
enum { Size = Sz };
#else
static const std::size_t Size = Sz;
#endif

public:
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;
}
---->8----

/usr/local/bin/g++ -V3.3 -O -DUSE_ANONYMOUS_ENUM -c compiler.cc
compiler.cc:26: 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>'
compiler.cc:20: Fehler: candidate is: template<class T, unsigned int Sz>
template<class T2> Vector& Vector::M_add_eq(const Vector<T2, Size>&)
compiler.cc:26: Fehler: template definition of non-template `Vector<T,
Sz>&
Vector<T, Sz>::M_add_eq(const Vector<T2, Vector<T, Sz>::Size>&)'

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

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
Olaf

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Anon Array The Owner Perl 0 02-26-2009 03:30 PM
Do constants need to be in anon-clk'd process's sensitivity list if they are i/ps neilmac VHDL 2 02-07-2008 02:43 PM
Enums without identifier, enums and typedef =?utf-8?b?QXNiasO4cm4gU8OmYsO4?= C Programming 10 01-20-2007 01:20 AM
Caller ID box with anon call reject Richard NZ Computing 7 12-15-2005 06:51 PM
jdeveloper - compile anon inner class with exception john Java 0 11-30-2005 01:07 PM



Advertisments