$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: [boost] [type_traits] has_member_function_callable_with
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2011-09-15 17:18:58
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:
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.
Best,
Ion