Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r69960 - branches/msm/v2_30/libs/msm/example
From: christophe.j.henry_at_[hidden]
Date: 2011-03-13 12:53:20


Author: chenry
Date: 2011-03-13 12:53:19 EDT (Sun, 13 Mar 2011)
New Revision: 69960
URL: http://svn.boost.org/trac/boost/changeset/69960

Log:
updated
Text files modified:
   branches/msm/v2_30/libs/msm/example/lambda.cpp | 17 +++++++++--------
   1 files changed, 9 insertions(+), 8 deletions(-)

Modified: branches/msm/v2_30/libs/msm/example/lambda.cpp
==============================================================================
--- branches/msm/v2_30/libs/msm/example/lambda.cpp (original)
+++ branches/msm/v2_30/libs/msm/example/lambda.cpp 2011-03-13 12:53:19 EDT (Sun, 13 Mar 2011)
@@ -33,6 +33,7 @@
 
     // 2. simple STL algorithm
     std::vector<int> vec(12);
+
     std::transform(vec.begin(),vec.end(),vec.begin(),lambda[ ++_1] );
     BOOST_ASSERT(vec[10] == 1);
 
@@ -47,16 +48,16 @@
 
     // 5. a taste of 0x: capturing
     int q=4;
- std::transform(vec.begin(),vec.end(),vec.begin(),lambda[_params << q ][ _c1 + _1] );
+ std::transform(vec.begin(),vec.end(),vec.begin(),lambda[_capture << q ][ _c1 + _1 ] );
     BOOST_ASSERT(vec[10] == 10); // was 6, now 6+4
 
     // 5.1 capturing by value (_c1 not modified)
- std::transform(vec.begin(),vec.end(),vec.begin(),lambda[_params << q ][ ++_c1 ] );
+ std::transform(vec.begin(),vec.end(),vec.begin(),lambda[_capture << q ][ ++_c1 ] );
     BOOST_ASSERT(vec[10] == 5); //always 4+1
    
     // 5.2 capturing by ref (_c1 modified at each call)
     int p=0;
- std::transform(vec.begin(),vec.end(),vec.begin(),lambda[_params << boost::ref(p) ][ _c1++ ] );
+ std::transform(vec.begin(),vec.end(),vec.begin(),lambda[_capture << boost::ref(p) ][ _c1++ ] );
     BOOST_ASSERT(vec[0] == 0);
     BOOST_ASSERT(vec[1] == 1);
     BOOST_ASSERT(vec[2] == 2);
@@ -65,7 +66,7 @@
     //this will correctly will not compile (const)
     //std::transform(vec.begin(),vec.end(),vec.begin(),lambda[_params << boost::cref(p) ][ _c1++ ] );
     // this will: _c1 not modified
- std::transform(vec.begin(),vec.end(),vec.begin(),lambda[_params << boost::cref(q) ][ _1 + _c1 ] );
+ std::transform(vec.begin(),vec.end(),vec.begin(),lambda[_capture << boost::cref(q) ][ _1 + _c1 ] );
     BOOST_ASSERT(vec[1] == 5); // 1 + 4
 
     // 6. using user functions
@@ -73,13 +74,13 @@
     std::transform(vec.begin(),vec.end(),vec.begin(),lambda[ _1 + foo_(_1)] );
     BOOST_ASSERT(vec[1] == 11); // 5 from before + (5+1)
 
- std::transform(vec.begin(),vec.end(),vec.begin(),vec.begin(),lambda[_params << 4 ][ foo_(_1 + _c1) ] );
+ std::transform(vec.begin(),vec.end(),vec.begin(),vec.begin(),lambda[_capture << 4 ][ foo_(_1 + _c1) ] );
     BOOST_ASSERT(vec[1] == 16); // foo(11 + 4)
 
     // 7. a bit of everything ;-)
 
     // 2nd form of transform
- std::transform(vec.begin(),vec.end(),vec.begin(),vec.begin(),lambda[_params << 2 ][ (_1 + _2) * _c1] );
+ std::transform(vec.begin(),vec.end(),vec.begin(),vec.begin(),lambda[_capture << 2 ][ (_1 + _2) * _c1] );
     BOOST_ASSERT(vec[1] == 64); // (16+16)*2
 
     // if clause executing 2 statements, returning the second one (not C++ ;-) )
@@ -89,7 +90,7 @@
 
     // completely useless but so fun :)
     vec[1] = 1;
- std::transform(vec.begin(),vec.end(),vec.begin(),lambda[_params << 10 ]
+ std::transform(vec.begin(),vec.end(),vec.begin(),lambda[_capture << 10 ]
         [
             if_(_1) /* true */
             [
@@ -99,7 +100,7 @@
                 ]
                 /* else */
                 [
- --_1
+ --(--_1)
                 ]
             ]
             /* else */


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk