[C++-sig] Re: def with name parser

Leonard "paniq" Ritter paniq at paniq.org
Thu Mar 10 22:40:39 CET 2005


argh, yes, crap. i dont know why i thought it would work.

wish my favorite compiler flavor would offer a bit more reflection :)

David Abrahams wrote:

>Stefan Seefeld <seefeld at sympatico.ca> writes:
>
>  
>
>>Leonard "paniq" Ritter wrote:
>>    
>>
>>>as far as i see, the second method is also possible as a template,
>>>and using overloads multiple versions of that def can be supported
>>>here's the simplest case, bit of pseudo
>>>template <typename L, typename T>
>>>L& def_autoname(T func)
>>>{
>>>   return def(parse(typeid(func).name()),func);
>>>}
>>>      
>>>
>>There is no guarantee that typeid(func).name() == "func", with gcc it is not.
>>It is mangled, and so not what you want.
>>    
>>
>
>Regardless, the function name has nothing to do with its type.
>
>    int foo();
>    int bar();
>    assert(typeid(foo) == typeid(bar));
>
>  
>




More information about the Cplusplus-sig mailing list