| I l@ve RuBoard |
|
2.9 NullType and EmptyTypeLoki defines two very simple types: NullType and EmptyType. You can use them in type calculations to mark certain border cases. NullType is a class that serves as a null marker for types:
class NullType {};
You usually don't create objects of type NullType—its only use is to indicate "I am not an interesting type." Section 2.10 uses NullType for cases in which a type must be there syntactically but doesn't have a semantic sense. (For example: "To what type does an int point?") Also, the typelist facility in Chapter 3 uses NullType to mark the end of a typelist and to return "type not found" information. The second helper type is EmptyType. As you would expect, EmptyType's definition is
struct EmptyType {};
EmptyType is a legal type to inherit from, and you can pass around values of type EmptyType. You can use this insipid type as a default ("don't care") type for a template. The typelist facility in Chapter 3 uses EmptyType in such a way. |
| I l@ve RuBoard |
|