1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
tt(Enum) types usually define symbolic values. However, this is not
required. In section ref(DYNAMICCAST) the tt(std::bad_cast) type was
introduced. A tt(bad_cast) is thrown by the tt(dynamic_cast<>) operator
when a reference to a base class object cannot be cast to a derived
class reference. The tt(bad_cast) could be caught as type, irrespective
of any value it might represent.
Types may be defined hi(type: without values) without any associated
values. An emi(empty enum) can be defined which is an tt(enum) not defining
any values. The empty enum's type name may thereupon be used as a legitimate
type in, e.g. a hi(catch: empty enum) tt(catch) clause.
The example shows how an empty enum is defined (often, but not necessarily
within a ti(class)) and how it may be thrown (and caught) as exceptions:
verbinclude(-a examples/emptyenum.cc)
|