Boost logo

Boost Users :

Subject: Re: [Boost-users] [type traits / MPL] check whether a class has a certain member function
From: Jeffrey Lee Hellrung, Jr. (jeffrey.hellrung_at_[hidden])
Date: 2013-03-07 14:12:36


On Thu, Mar 7, 2013 at 5:44 AM, Stefan Strasser <strasser_at_[hidden]>wrote:

> Am 07.03.2013 04:58, schrieb Edward Diener:
>
>> The macro you're looking for is BOOST_TTI_HAS_MEMBER_FUNCTION.
>>> However, I don't think this has been released yet. It's in the
>>> trunk, but I don't see it in the release branch.
>>>
>>
>> I am fairly close to finishing my work with TTI, but it is not yet in
>> release.
>>
>>
> Thanks, it works as advertised.
>
> However, it requires you to know the exact signature of the member
> function. I'm trying to check whether it is ok to call c.f(x), which would
> be satisfied by each of the following 3 signatures (and more):
>
> struct C{
> void f(X);
> void f(X &);
> void f(X const &);
> ...
> };
>
> is there a way to check for that, or do I have to check for all (likely)
> signatures?
> there is a way to check whether a function call is ok without knowing the
> signature using c++11:
>
> http://stackoverflow.com/**questions/11273184/sfinae-**
> member-function-existence-**test-issue<http://stackoverflow.com/questions/11273184/sfinae-member-function-existence-test-issue>
>
> I'm not sure if you can do the same in c++03.
>

This, and the referenced link in Russian, might help

https://groups.google.com/group/comp.lang.c++.moderated/tree/browse_frm/thread/4f7c7a96f9afbe44/c95a7b4c645e449f?pli=1#doc_e5fbc9305539f699

- Jeff



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