Virual types for static hierarchies . More...
#include <wipal/tool/static_base.hh>
Virual types for static hierarchies .
In static hierarchies it is often desirable to define virtual types. That is, types that will be defined in subclasses but must exist in the parent class. (e.g. iterable provides an iterable::iterator
type, but this type is actually defined in iterable's subclasses.) For technical reasons, one must define virtual types in external classes. This is types's role.
Declare foo
's virtual types in types<foo>
:
template <> struct types<foo> { typedef bar type1; typedef baz type2; };
Inside a class, access a virtual type with the WP_TYPE()
preprocessor macro.
E.g.
template <class Bottom> struct iterable : public WP_INHERIT(public static_base, iterable<Bottom>) { typedef WP_GET_EXACT(Bottom, iterable<Bottom>) exact_type; typedef WP_TYPE(iterator, exact_type) iterator; // ... };