Brian Riis Guest
|
Posted: Fri Oct 15, 2004 11:13 pm Post subject: Yves Meynard's Enumeration class (CUJ May 2003) |
|
|
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! ]
|
|