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

David Abrahams dave at boost-consulting.com
Thu Mar 10 21:26:39 CET 2005


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));

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com




More information about the Cplusplus-sig mailing list