Boost logo

Boost :

From: Trey Jackson (tjackson_at_[hidden])
Date: 2003-02-20 20:51:43

Jaakko wrote:
>I was doing something like it recently, so, sure:


>template <class DataType, class FunctionType = boost::function1<void,
>DataType> >
>class work_crew {
> std::list<DataType> queue_;
> FunctionType engine_;
> work_crew(FunctionType const& tocall);
> void add(DataType d) { queue_.push_front(d); };
> void dowork()
> {
> typedef typename std::list<DataType>::iterator iterator_t;
> for (iterator_t iter = queue_.begin(); iter != queue_.end(); ++iter)
> tuples::apply(this->engine_, *iter); // here
> };

Question: does the above work even if my work_crew is still the

    work_crew< int, boost::function<void, int> > vanillaCrew(....);

or would I need

    work_crew< tuples::tuple<int>, boost::function<void, int> > closeToVanillaCrew(....);

- I ask b/c of the 'tuples::apply(...)' portion.
At first glance, it's not clear that

   int i;
   tuples::apply(this->engine_, i)

would not work (b/c i is not a tuple).

>With a little bit more of coding and Boost.MPL, you can do even better on
> work_crew< tuples::tuple<int,int>, boost::function2<void,int,int> >
> mycrew(bind(&X::f, &x, _1, _2));
> work_crew< mpl::list<int,int> > mycrew(bind(&X::f, &x, _1, _2));

I'll look into that later, it'd be exciting.

Hopefully I'll be able to see this in 1_30_0! ;-)


Trey Jackson
"Failure is not an option. It comes bundled with your Microsoft product."
-- Ferenc Mantfeld

Boost list run by bdawes at, gregod at, cpdaniel at, john at