Boost logo

Boost :

Subject: Re: [boost] [type_traits] has_member_function_callable_with
From: Edward Diener (eldiener_at_[hidden])
Date: 2011-09-15 19:07:51


On 9/15/2011 5:18 PM, Ion Gaztañaga wrote:
> Hi to all,
>
> Trying to port C++11 code (allocator_traits) to C++03 (without decltype
> support), I needed to check at compile time if a member function can be
> called with some given parameters.
>
> Typical solutions I found on the net were based on specific signatures,
> say:
>
> const bool value =
> HAS_MEMBER_FUNCTION_FUNCNAME_WITH_SIGNATURE(MyClass, (int, char*));
>
> However, it is not feasible to know the exact signature as I want to
> deal with conversions, const references, etc. Luckily, I found a very
> interesting explanation in Proto documentation:
>
> http://www.boost.org/doc/libs/1_47_0/doc/html/proto/appendices.html#boost_proto.appendices.implementation.function_arity
>
>
> Based on this, I've tried to write my solution and I'd like to share it
> here with type traits experts, in case someone knows a better solution
> (see attached example). I know I don't take into account many issues for
> a truly generic utility (const member functions, etc.) but please let me
> know if you find this example interesting.

Thanks, Ion, I definitely want to look at your solution. I also know the
link above as it has come up before.

In TTI one can test for an exact signature but I want to pursue
solutions based on Eric Niebler's Proto explanation and your solution
also for future enhancements.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk