On 3/7/2013 3:53 PM, Stefan Strasser wrote:
Am 07.03.2013 20:12, schrieb Jeffrey Lee Hellrung, Jr.:
The macro you're looking for is BOOST_TTI_HAS_MEMBER_FUNCTION.
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?
https://groups.google.com/group/comp.lang.c++.moderated/tree/browse_frm/thre...
Thanks! it doesn't work for me, because it uses sizeof(void) if the function call is possible.
However, it is enough to determine whether a member of a given name exists, without checking the signature. an implementation of has_member is here: http://www.rsdn.ru/forum/cpp/2720363
Edward, can this be added to TTI, for example as BOOST_TTI_HAS_MEMBER? not only does this implementation look portable to me, but boost already uses it internally: http://www.boost.org/doc/libs/1_47_0/boost/thread/locks.hpp
I agree that having a TTI metafunction to check for a member function by name with any signature might be helpful. But even in your situation above, just knowing that some 'f' exists within 'C' does not tell you it is callable by passing 'X', 'X &', or 'X const &'. Nonetheless I will look into the links presented by you and Jeffrey Hellrung, especially the last above. First I need to finish my work and get TTI into Boost. I am very near the end of making coding changes as suggested by the review and largely have some more documentation and tests on some compilers ( Intel and Sun ) to do. Gcc, clang, and VC++ are working fine so far with TTI and an occasional workaround ( VC++ and some slightly older versions of gcc ). My major concern is how much time I should spend on trying to invent workarounds for compilers whose implementations of SFINAE are insufficient in certain situations need by TTI. But I think its most important just getting TTI into Boost, documenting what does not work on certain less SFINAE deficient compilers, and then look for possible workarounds later. The vast majority of C++ programmers probably use gcc, VC++, or clang nowadays. I have also delayed much too long in getting TTI fully ready for Boost and into the release branch and just need to get it done.