2 virtual-methods.hh -- declare macros for our do-it-yourself RTTI
4 source file of the Flower Library
6 (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #ifndef VIRTUAL_METHODS_HH
11 #define VIRTUAL_METHODS_HH
14 #include "stdlib.h" // size_t
16 #define classname(class_ptr) demangle_classname(typeid(*(class_ptr)).name())
19 demangle_classname (const char*);
23 Virtual copy constructor. Make up for C++'s lack of a standard
24 clone() function. Uses a typeof hack. Usage:
26 class Foo : Baseclass {
27 VIRTUAL_COPY_CONS(Baseclass);
31 #define VIRTUAL_COPY_CONS(base) virtual base *clone () const { return new typeof(*this) (*this); }