Yesterday I was in need for a more advanced form of enumeration in C++, something similar to Java Enumeration classes. But C++ only supports the basic C enum.
This can be fine for many things, but I am looking for a more sophisticated solution like the one in the Dr. Dobb's portal 2003 article "When enum Just Isn't Enough: Enumeration Classes for C++" at http://www.ddj.com/dept/cpp/184403955. It seems the link is wrong: the code is in a zip file at ftp://ftp.cuj.com/pub/2003/cujmay2003.zip (and then in meynard.zip).
I must say that I am fairly new in template programming but i get the basic idea of Yves Meynard's Enum templates.
I am on windows using MinGW (GCC 3.4.2) and the code simply will not compile. I am getting some compiler errors:
line 47 Enum.h type `std::set<const Enum<T>*, Enum<T>::Enum_P tr_Less, std::allocator< const Enum<T>*> >' is not derived from type `Enum<T>'
line 47 Enum.h ISO C++ forbids declaration of `size_type' with no type
---
I was wondering if anybody could give some advise on the code in the article - whether or not it will compile ever with gcc 3.4.2 in MinGW? What changes could I do such that it would work?
Thanks, kofler
This can be fine for many things, but I am looking for a more sophisticated solution like the one in the Dr. Dobb's portal 2003 article "When enum Just Isn't Enough: Enumeration Classes for C++" at http://www.ddj.com/dept/cpp/184403955. It seems the link is wrong: the code is in a zip file at ftp://ftp.cuj.com/pub/2003/cujmay2003.zip (and then in meynard.zip).
I must say that I am fairly new in template programming but i get the basic idea of Yves Meynard's Enum templates.
I am on windows using MinGW (GCC 3.4.2) and the code simply will not compile. I am getting some compiler errors:
line 47 Enum.h type `std::set<const Enum<T>*, Enum<T>::Enum_P tr_Less, std::allocator< const Enum<T>*> >' is not derived from type `Enum<T>'
line 47 Enum.h ISO C++ forbids declaration of `size_type' with no type
---
I was wondering if anybody could give some advise on the code in the article - whether or not it will compile ever with gcc 3.4.2 in MinGW? What changes could I do such that it would work?
Thanks, kofler