Boost logo

Boost Users :

Subject: Re: [Boost-users] BOOST_FOREACH question
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-06-17 18:51:02


AMDG

Zachary Turner wrote:
> std::for_each(
> boost::make_zip_iterator(boost::make_tuple(inputs.begin(),
> outputs.begin())),
> boost::make_zip_iterator(boost::make_tuple(inputs.end(),
> outputs.end())),
> boost::bind(
> &boost::asio::io_service::post,
> &work_io_service_,
> boost::bind(
> &EncoderService::encode_handler,
> this)));
> }
>

Nested binds are treated specially. You need to use boost::protect.
However, you're still left with the problem that there's no good way
to propagate the zip_iterator value from the outer bind to the inner bind.

What you really want is something like this, although it won't quite work,
because boost::bind is an overloaded function template
boost::bind(
    &boost::asio::io_service::post,
    &work_io_service,
    boost::bind(
        &boost::bind,
        &EncoderService::encode_handler,
        this,
        _1))

> void encode_handler(const boost::tuple<const_buffer, mutable_buffer>& buffers)
> {
> }
>

In Christ,
Steven Watanabe


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