
On 12/07/2005 05:47 AM, Frank Laub wrote:
Hello fellow boosters,
I've recently come up with a way to use the boost preprocesor to generate a 'better' enum type. The following is an example of some typical usage. Is anyone else interested in this sort of thing? I'm hoping to get suggestions
I'm interested.
for how to make it more 'boost-like' in both its implementation and its usage. Is this very readable? Is there a place I can upload the code for people to peruse?
The boost file vault: http://boost-consulting.com/vault/ under the 'Preprocessor Metaprogramming' directory.
#include <iostream> #include <boost/enum.hpp> #include <boost/foreach.hpp> #define foreach BOOST_FOREACH
BOOST_ENUM(Level, (Abort)("unrecoverable problem") (Error)("recoverable problem") (Alert)("unexpected behavior") (Info)("expected behavior") (Trace)("normal flow of execution") (Debug)("detailed object state listings") )
int main() { foreach(const string& name, Level::names) { cout << name << endl; }
[snip] Tha above looks great, and I remember, several weeks or months ago, there was a request for just such a utility on comp.lang.c++.moderated. Thanks.