|
Boost Users : |
Subject: Re: [Boost-users] Using SFINAE to detect presence of member function - Unreliable
From: Joel Falcou (joel.falcou_at_[hidden])
Date: 2009-01-30 09:17:36
Naik, Roshan a écrit :
> So .. my question is ....does anyone have solution that works for the case
> when the method is defined in the base class too ?
>
> I am thinking ... if it is possible to extract the class name from the
> actual type of &Derived::foo, then the problem can be solved... but the type
> extraction mechanism must not error out on types that have absolutley no
> member function called foo.
>
I stumbled across this problem recently. My only fix that still need to
be added to my introspection prototype is to have a
HAS_INHERITED_MEMBER_FUNCTION( method, prototype,
(list)(of)(base)(class)(as)(a)(PP_Sequence));
that do a compound check on a given type to see if T::method or any
(base class)::method exists, performing a or_ on the result.
eg :
class Base1 { void foo(int); };
class Base2;
class Foo : public Base1, public Base2 {};
HAS_INHERITED_MEMBER_FUNCTION(foo, void(int), (Base1)(Base2) );
in which : has_inherited_member_function<Foo>::value will return true.
It's cumbersome has the base classes of Foo need to be explicited in the
macro.
Retrieving the base class from the derived type seems quite hard though
and I really do'nt see hwo you can do it.
-- ___________________________________________ Joel Falcou - Assistant Professor PARALL Team - LRI - Universite Paris Sud XI Tel : (+33)1 69 15 66 35
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net