As far as I know boost::phoenix is not an officially released boost lib. It is still part of boost::spirit library. There is no top level reference to it. So I would not consider it for now to be a replacement for bind and lambda. It might become, but don't rely on that. ;) Anyway here the rewritten example:
#include <boost/spirit/home/phoenix/core.hpp>
#include <boost/spirit/home/phoenix/scope.hpp>
#include <boost/spirit/home/phoenix/operator.hpp>
#include <boost/spirit/home/phoenix/function.hpp>
#include <algorithm>
#include <vector>
#include <iterator>
#include <iostream>
using namespace std;
using namespace boost;
using namespace boost::phoenix;
using namespace boost::phoenix::arg_names;
using namespace boost::phoenix::local_names;
namespace ph = boost::phoenix;
int main( )
{
vector< int > v;
// generate vector values
int i=0;
generate_n(back_inserter(v), 100, ++ph::ref(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(), arg1*=2);
copy(v.begin(), v.end(), oiter);
cout << endl;
}
Regards,
Ovanes