|
Boost Users : |
Subject: Re: [Boost-users] Using SFINAE to detect presence of member function - Unreliable
From: Naik, Roshan (roshan.naik_at_[hidden])
Date: 2009-02-02 14:54:50
Seems like the following specialization of impl<> works:
template <typename r>
struct impl<true, r(void)>
{
static const bool value =
sizeof(
return_value_check<type, r>::deduce( (
(((derived_type*)0)->operator()(), details::void_exp_result<type>())
) )
) == sizeof(yes);
};
-Roshan
From: boost-users-bounces_at_[hidden] [mailto:boost-users-bounces_at_[hidden]] On Behalf Of Roman Perepelitsa
Sent: Monday, February 02, 2009 1:57 AM
To: boost-users_at_[hidden]
Subject: Re: [Boost-users] Using SFINAE to detect presence of member function - Unreliable
2009/1/31 Naik, Roshan <roshan.naik_at_[hidden]<mailto:roshan.naik_at_[hidden]>>
> Maybe this one does what you need:
> http://groups.google.com/group/comp.lang.c++.moderated/tree/browse_frm/thread/4f7c7a96f9afbe44/c95a7b4c645e449f#doc_e5fbc9305539f699
Thanks Roman. It is kind of amazing! Both has_member<> and is_call_possible<> are very interesting (even if a bit ugly).
But is_call_possible doesn't seem to work for member functions that don't have any arguments. I tried twiddling with the implementation a bit and no luck yet.
Sorry, I don't know how to make it work for functions without arguments. Problem is that this program is invalid:
void foo() {}
void foo(...) {}
int main() {
foo(); // Ambiguous.
}
Roman Perepelitsa.
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