1 // (C) Copyright Vesa Karvonen 2004.
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE.)
11 // To demonstrate the use of the `ENUM'-macro, we'll write a simple
12 // `ENUM'-specification:
16 (from_the_files_of_police_squad
, 1)
18 (the_final_insult
, 33))
20 // Then we'll use the generated conversion functions and output the
21 // strings returned by the `to_string'-function:
25 << to_string(to_naked_gun("from_the_files_of_police_squad"))
27 << to_string(to_naked_gun("the_smell_of_fear"))
29 << to_string(to_naked_gun("the_final_insult"))
37 // The conversion from the value of an enumerator to a string can be
38 // done in constant time easily when the values of the enumerators
39 // are known to be consecutive. This is known to be the case when
40 // all but the first enumerator use the default value. Implement the
41 // constant time conversion as an optimization.
45 // Extend the `ENUM'-macro to optionally generate a standard stream
46 // inserter and a stream extractor for the defined enumerated type.
50 // Extend the `ENUM'-macro to optionally generate constructors for
51 // the enumerated type. The constructors should check that that the
52 // specified integral value or string identifier is one of the
53 // enumerators and throw an exception if that is not the case.