|
Boost : |
From: hugo.duncan_at_[hidden]
Date: 2002-02-15 18:08:10
To learn about the preprocessor library I wrote a
macro (yuck) to generate an enum class, with iterators
and named values. The code is attatched for anyone
interested.
It allows code like:
#define TEST_LIST
BOOST_PP_TUPLE_TO_LIST(4,(aa,bb,c_xyz,d))
ENUM_CLASS( my_enum, TEST_LIST );
std::cout << my_enum::c_xyz << std::endl;
for (my_enum::iterator i=my_enum::begin();
i!=my_enum::end(); ++i)
std::cout << *i << " " << my_enum::name(*i) <<'\n';
which produces
2
0 aa
1 bb
2 c_xyz
3 d
(See attached file: enumeration.hpp)
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk