On Friday 18 August 2006 08:34, Tobias Schwinger wrote:
Peter Soetens wrote:
On Saturday 12 August 2006 23:21, Tobias Schwinger wrote: [...]
BTW: Not removing the class type (creating a function that takes the class context in form of a properly cv-qualified reference) is even simpler:
function_pointer<F>::type // is 'bool (*)(X &,int)' for F = 'bool (X::*)(int)' // is 'bool (*)(X const &,int)' for F = 'bool (X::*)(int) const'
Thanks, but I wanted the X& to be a pointer as well. OTOH, maybe I can change my code to pass a reference to X.
function_pointer<F>::type
is a shortcut for
function_pointer< components<F> >::type
and 'components' has a second template parameter, an MPL Lambda Expression, that allows to change the way the class type is transformed (and so has 'parameter_types'):
function_pointer< components< F, add_pointer<_> >::type // is 'bool (*)(X *,int)' for F = 'bool (X::*)(int)' // is 'bool (*)(X const *,int)' for F = 'bool (X::*)(int) const'
function_pointer< components< F, add_pointer< remove_cv<_> > >::type // is 'bool (*)(X *,int)' for F = 'bool (X::*)(int)' // is 'bool (*)(X *,int)' for F = 'bool (X::*)(int) const'
This is a complete killer-template. You are a genious. If this becomes the 'look-and-feel' interface of the whole library (instead of the 'tags'), it will be an example for many other meta programming libraries. Peter -- Peter Soetens -- FMTC -- http://www.fmtc.be