
AMDG strasser@uni-bremen.de wrote:
Zitat von Steven Watanabe
: Yes. The code looks something like this:
typedef char no; struct yes { char dummy[2]; };
struct has_on_result { has_on_result operator,(int); };
no check_on_result(const has_on_result&); yes check_on_result(...);
template<class T> struct has_on_impl : T { using T::on; has_on_result on(...); };
template
struct has_on : boost::mpl::bool_< sizeof(check_on_result(((has_on_impl<T>*)0)->on(*((M*)0)) , 0)) != sizeof(no) {};
how does this work with member functions that have a "void" result? does it?
It handles void. That's what the comma operator is for.
how does this work at all? "using T::on" is invalid when T doesn't have "on", so the instantiation of has_on<>, that should result in mpl::false_, fails.
Requiring at least one overload of on, is not particularly onerous in this context. If you're willing to require the exact signature, you can use SFINAE as in Kim's post.
do you have a link to actual code that uses this?
I think proto uses something like this for operator(). There are a few extra tricks that work for this however. In Christ, Steven Watanabe