Boost logo

Boost :

Subject: Re: [boost] Is there interest in a library for testing existence of a function member of class?
From: ºúά (huwei04_at_[hidden])
Date: 2014-11-24 01:23:06

> >>
> >
> > Yes, it's in Boost.TTI:
> Has anyone ever worked out how to do this without having to specify
> the type? E.g. with BOOST_TTI_HAS_MEMBER_DATA I need to write
> something like
> has_member_data_fieldname<int ClasdName::*>::value;
> The most recent time I needed something like this, I wanted to test
> whether a struct contained a field with a particular name that was
> convertible to a float (I think float or int16_t in that case).
> I would have been happy with a test for a field with that name of
> any type. But I couldn't work out how to do it. Any ideas?

I just realized that BOOST_TTI_HAS_MEMBER_FUNCTION is not exactly same as mine.BOOST_TTI_HAS_MEMBER_FUNCTION will check the type signature and only return true if it's exactly match.
I would like to test if a member function of class is 'applicable'.
For example, below code will print 0, but I expect to get 1.BOOST_TTI_HAS_MEMBER_FUNCTION(foo)
class a{public: int foo(int);};
int main(){ std::cout << has_member_function_foo<int (a::*)(double)>::value << std::endl; return 0;}

Boost list run by bdawes at, gregod at, cpdaniel at, john at