
On 03/26/2011 03:19 PM, Lorenzo Caminiti wrote:
Hello all,
I am updating Boost.Local docs and I could use a some help in getting the Alternatives section right http://svn.boost.org/svn/boost/sandbox/local/libs/local/doc/html/boost_local... .
How can I program the following code (its local function and `factor` constant binding) using Boost.Phoenix, Boost.Lambda, and C++0x lambda functions? If you know, can you please reply with the actual code?
Phoenix version: #include <boost/phoenix/phoenix.hpp> #include <boost/phoenix/statement.hpp> #include <iostream> #include <vector> #include <algorithm> int main() { double sum = 0.0; int factor = 10; using namespace boost::phoenix; using namespace boost::phoenix::placeholders; std::vector<double> v(3); v[0] = 1.0; v[1] = 2.0; v[2] = 3.0; std::for_each(v.begin(), v.end(), ( ref(sum) += factor * _1, std::cout << "Summed: " << ref(sum) << "\n" ) ); return 0; } -- Michael Caisse Object Modeling Designs www.objectmodelingdesigns.com