next up previous index
Next: Comments Up: Implementation of the Previous: The RTTI_DEF and

Implementation of Dynamic Typeids

Section 4.4 introduced the dynamic typeid concept, represented by the dyn_typeid class. As explained, this class is useful when the user wishes to create a 'dummy' typeid from a textual name and pass it, for example, to the TYPE_NEW operation.

Class dyn_typeid is similar to typeid in that it is a 'proxy' to a Type_info. However, a dyn_typeid can be constructed also from a textual type description (i.e. a char*). This will create a 'dummy' Type_info which contains only the name field.

Since dyn_typeid can be only used for passing it as argument to the typeid::create() method, we declare this method as accepting dyn_typeids and we derive typeid from dyn_typeid and not conversely. Thus a typeid can be used as a dyn_typeid but not conversely. Moreover, methods using dyn_typeids like typeid::create() will be aware that they should only access the type name.



Alexandru Telea