Boost logo

Boost Users :

Subject: Re: [Boost-users] Auto dispatch metaprogramming tricks
From: strasser_at_[hidden]
Date: 2010-05-21 09:56:12


Zitat von Steven Watanabe <watanabesj_at_[hidden]>:

>
> 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<class T, class M>
> 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?

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.

do you have a link to actual code that uses this?

thanks


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