473,396 Members | 1,767 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

anon enums porting problem

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

Nov 8 '05 #1
0 1428

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: SpaceCowboy | last post by:
I recently got into a discussion with a co-worker about using enums across a dll interface. He wanted to use chars instead, argueing that depending on compiler settings the size of an enum could...
27
by: Mark A. Gibbs | last post by:
i have been toying with the idea of making my enums smarter - ie, more in line with the rest of the language. i haven't tested it yet, but what i came up with is a template like this: template...
9
by: Simon Elliott | last post by:
I'm porting thousands of lines of legacy C code to C++. One makor issue I've got is that of enums being treated differently in C and C++. There's an automatic cast from int to enum in C but not in...
9
by: Jarmo Muukka | last post by:
Hello all! I have used C++ for many years and recently I have used C#. Now I am coding in C++ and I have a problem now. In C# you can do enums like this: enum Lane { Left,
4
by: Martin Pritchard | last post by:
Hi, I'm working on a project that historically contains around 40 enums. In the database various fields refer to the int values of these enums, but of course ref integrity is not enofrced and...
1
by: Bae,Hyun-jik | last post by:
Is there any way to port legacy C++ enum to managed object? For example, let's assume there is a C++ header file(we cannot modify it, because it is updated by other vendor). It has a enum...
3
by: lou zion | last post by:
hi all, i'm trying to use a classes enums in another class, but can't seem to find the right syntax. i've got class A which has: enum EditTypeA {Currency, Percent, LabeledNumber, Text};...
2
by: David Veeneman | last post by:
I want to data bind a user control and a business object, using a BindingSource control. The control has a 'Priority' property that takes a 'Priority' enum (High, Normal, Low). The business object...
13
by: Bob | last post by:
Hi, Can someone explain why you can't declare enums in an interface? The compiler says "interfaces can't declare types" Ignoring the syntax implications it seems to me that you should be able to...
37
by: Ian Semmel | last post by:
If I have Enum en { i1, i2, i3 } I reckon I should be able to have
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.