Boost logo

Boost Users :

Subject: [Boost-users] [Bind] Binding a sequence of operations.
From: Robert Jones (robertgbjones_at_[hidden])
Date: 2011-05-20 09:24:16


Hi All

Is it possible to write this code as a for_each/bind combination?

I know I could do this with Boost.Lambda or Boost.Phoenix, which is my
solution of last resort, but can it be done with plain Boost.Bind?

What I think I'm missing is a bindable sequence operator - is there any such
thing?

Thanks, Rob

#include <vector>
#include <boost/bind.hpp>
#include <boost/range.hpp>

struct X { };

void do_this( const X & );
void do_that( const X & );

typedef std::vector<X> Xs;

int main( )
{
    Xs xs;

    for( Xs::const_iterator x = boost::begin(xs); x != boost::end(xs); ++x )
    {
        do_this( * x );
        do_that( * x );
    }
}



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