On Tue, Mar 23, 2010 at 2:19 PM, Robert Jones <robertgbjones@gmail.com>wrote:
Thanks Ovanes - I'm sure you will understand that my real code is a bit more complicated then doubling ints! Since both bind and lambda are pretty much superceded by phoenix now, perhaps you could also supply the phoenix version?
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