Boost logo

Boost Users :

Subject: Re: [Boost-users] [mpl - function_types] Generate typedef from operator() of a functor
From: joel falcou (joel.falcou_at_[hidden])
Date: 2010-01-30 10:28:30


Olivier Tournaire wrote:
> Hi all,
>
> Given an mpl sequence of types such as: typedef mpl::vector<T0, T1,
> T2, T3> arg_types;
>
> 1) the users of my library provide functors such as F (where T0 and T1
> may have been any of the types of arg_types:
>
> class F {
> typedef mpl::pair<T0,T1> signature_type;
> double operator()(const T0& t0, T1& t1);
> };
> is there a way to generate signature_type automatically ?
>
Retrieve the operator() params usign aprameter_types, it'll end up as

vector<F*,T0,T1>

then use mpl::pop_front to remove the unwanted pointer to member

> 2) if the operator() is overloaded, the user class currently has to
> typedef an mpl::vector of mpl::pairs such as
>
> class G {
> typedef mpl::vector<mpl::pair<T2,T3>, mpl::pair<T1,T1>,
> mpl::pair<T3,T1> > signature_type;
> double operator()(const T2& t2, T3& t3);
> double operator()(const T1& t1, T1& t1);
> double operator()(const T3& t3, T1& t1);
> };
>
Why don't you use something like the result_of protocol ?
Maybe easier

-- 
___________________________________________
Joel Falcou - Assistant Professor
PARALL Team - LRI - Universite Paris Sud XI
Tel : (+33)1 69 15 66 35

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