File: emptyenum.yo

package info (click to toggle)
c%2B%2B-annotations 12.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 13,044 kB
  • sloc: cpp: 24,337; makefile: 1,517; ansic: 165; sh: 121; perl: 90
file content (15 lines) | stat: -rw-r--r-- 860 bytes parent folder | download | duplicates (5)
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)