Just in case you interested how to accomplish it with boost::lambda

#include "boost/lambda/lambda.hpp"

#include <algorithm>
#include <vector>
#include <iterator>
#include <iostream>

using namespace std;
using namespace boost;
namespace bll=boost::lambda;

int main( )
{
  vector< int > v;
  int i=0;
  // generate vector values
  generate_n(back_inserter(v), 100, ++bll::var(i));

  //create the output iterator
  ostream_iterator<int> oiter(cout, ",");
  copy(v.begin(), v.end(), oiter);
  cout << endl;

  // double each value in the vector
  for_each(v.begin(), v.end(), bll::_1*=2);    
  copy(v.begin(), v.end(), oiter);
  cout << endl;

  return 0;
}

Regards,
Ovanes

On Tue, Mar 23, 2010 at 10:49 AM, Robert Jones <robertgbjones@gmail.com> wrote:
#include <algorithm>
#include <vector>
#include "boost/bind.hpp"

struct A
{
    int double_it( int i ) { return i * 2; }
} a;

std::vector< int > v;

int main( )
{
    for ( std::vector< int >::iterator i = v.begin( ); i != v.end( ); ++ i )
    {
        a.double_it( * i );
    }

    // Write it as a for_each/bind
    std::for_each( v.begin(), v.end(), boost::bind( & A::double_it, boost::ref( a ), _1 ) );
}