[C++-sig] def with name parser

Leonard "paniq" Ritter paniq at paniq.org
Thu Mar 10 20:18:44 CET 2005


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

Stefan Seefeld wrote:

> Leonard "paniq" Ritter wrote:
>
>> however i'm not a big fan of macros so i'd like to see this included 
>> natively in boost.python somewhere. is that possible, or do we run 
>> into cross platform issues with this?
>
>
> What you suggest is only possible with macros. And as I share with you
> my aversion to macros, especially if they aren't strictly necessary, I'd
> suggest not to include such a macro into boost.python :-)
> Keep in mind that the form 'def("foo", foo)' only works in the simplest
> of cases. Most of the time you have a combination of other things such
> as policies, class names, etc. to add, so a simple minded macro approach
> wouldn't work anyways.
> I don't think the small number of key strokes it may save you is worth
> the trouble.
>
> FWIW,
>         Stefan
>
> _______________________________________________
> C++-sig mailing list
> C++-sig at python.org
> http://mail.python.org/mailman/listinfo/c++-sig
>
>




More information about the Cplusplus-sig mailing list