X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=flower%2Finclude%2Fvirtual-methods.hh;h=76ed3e9ea38baeb12846fb67cff101c6d97685ef;hb=0fcd8c283c45644a92d2308f1cd0d82a1e63380b;hp=03605d4135b171bf1eb82d4c95142931b82ac86f;hpb=48f2b9351f93d0161c675cfb60e95bf919041df2;p=lilypond.git diff --git a/flower/include/virtual-methods.hh b/flower/include/virtual-methods.hh index 03605d4135..76ed3e9ea3 100644 --- a/flower/include/virtual-methods.hh +++ b/flower/include/virtual-methods.hh @@ -3,52 +3,31 @@ source file of the Flower Library - (c) 1997--1999 Han-Wen Nienhuys + (c) 1997--2005 Han-Wen Nienhuys */ - #ifndef VIRTUAL_METHODS_HH #define VIRTUAL_METHODS_HH -#include "stdlib.h" // size_t +#include -#define classname(class_ptr) demangle_classname(typeid(*(class_ptr))) +#define classname(class_ptr) demangle_classname (typeid (* (class_ptr))) const char * -demangle_classname (type_info const &); - -/** - - Virtual copy constructor. Make up for C++'s lack of a standard - clone() function. Uses a typeof hack. Usage: +demangle_classname (std::type_info const &); - class Foo : Baseclass { - VIRTUAL_COPY_CONS(Baseclass); - }; - - */ +/* Virtual copy constructor. Make up for C++'s lack of a standard + factory or clone () function. Uses a typeof hack. Usage: -// fix constness: gcc-2.95 is correct in defining -// typeof (*this) -// in a const member function to be const + class Foo : Baseclass + { + VIRTUAL_COPY_CONSTRUCTOR (Baseclass, Foo); + }; */ -#if 0 -#define VIRTUAL_COPY_CONS(base) \ - virtual base *clone () const \ - { \ - return new typeof(*this) (*this); \ +#define VIRTUAL_COPY_CONSTRUCTOR(Base, name) \ + virtual Base *clone () const \ + { \ + return new name (*this); \ } -#else -#define VIRTUAL_COPY_CONS(base) \ - virtual base* clone_const_helper () \ - { \ - return new typeof (*this) (*this); \ - } \ - virtual base* clone () const \ - { \ - base* urg = (base*)this; \ - return urg->clone_const_helper (); \ - } -#endif #endif /* VIRTUAL_METHODS_HH */