C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Yves Meynard's Enumeration class (CUJ May 2003)

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
Brian Riis
Guest





PostPosted: Fri Oct 15, 2004 11:13 pm    Post subject: Yves Meynard's Enumeration class (CUJ May 2003) Reply with quote



Browsing through CUJ's archives, I stumbled over this article
([url]http://www.cuj.com/documents/s=8205/cujweb0305meynard/web0305d.htm)[/url],
and I really like the idea. I've been experimenting a bit with the
Tmpl_Enum<> class (Listing 5), since I have a collection that would
ideally be enumerated with std::string. With typical luck the thing,
naturally, wouldn't compile out-of-the-box, so I made a few changes, to
make gcc accept it (well, MinGW-3.4.2, actually).

In short, the private constructor has been made protected, I've added
"typename" to the two typedefs and the size() static member function.

Looking at the definition of the static member s_instances (Listing 6),
I had to add "template<>" to get it to compile, and I suspect this is
where my troubles lie.

template<>
Tmpl_Enum<std::string, Test_Enum_String>::instances_list
Tmpl_Enum<std::string, Test_Enum_String>::s_instances;

The linker complains that Tmpl_Enum<std::string,
Test_Enum_String>::s_instances is an undefined reference.

": undefined reference to `Tmpl_Enum
I suspect I'm cutting corners that really cannot be cut somewhere, but I
can't figure out where.

Has anyone successfully used this class? Is it worth the effort? Or is
there an easier way?

--
Brian Riis

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.