From: Prochnow, C. <pro...@se...> - 2005-05-29 17:54:08
|
Am Freitag 27 Mai 2005 19:09 schrieb stephan beal: > On Friday 27 May 2005 16:46, Prochnow, Christian wrote: > > but when using type_info::name().. the type_info object returns the > > mangled c++ ABI name of the type which _must_ be the same in all > > compilation units. > > > > see this: http://gnu.open-mirror.com/software/gcc/faq.html#dso > > i wish the GCC guys would all read that. ;) i will swear on my life i've > seen type_info::name() returns two different strings for the same type, > depending on their creation scope. That was way back in 3.0/3.1, too, > so maybe it doesn't happen anymore. > > In any case that page only applies to gcc. According to C++, what name() > returns is UNDEFINED. Scott Meyers covers this in detail in one of his > books. The way he puts it, even an implementation in which name() > returns an empty string for every class is fully compliant with the > standard. Not useful, but compliant. i will keep that in mind for further investigation... > > i think we can make the second argument a const reference type. > > That still requires instantiating it, a limitation i haven't ever needed > in a factory implementation. i've added a second Factory::registerType method which does not require constructing a temporary object. One could also use Factory::registerFactory like in your old implementation. Btw... you're old Factory implementation did also require constructing a temporary object ;-) see Factory.h Revision 1.21: -- template <typename TypeName> void registerType( const key_type & key, TypeName ) { registerFactory( key, Hook::FactoryCreateHook<InterfaceT,TypeName>::create ); } Greetings, Christian |