4 Jun
2008
4 Jun
'08
8:33 p.m.
void AddUserAge( int& age ) { ++age; }
int _tmain(int argc, _TCHAR* argv[]) { std::vector<_sUserData> vUserData; for( int i = 0; i < 10; ++i ) vUserData.push_back( _sUserData() ); std::for_each( vUserData.begin(), vUserData.end(), boost::bind( AddUserAge, boost::bind( &_sUserData::m_nUserAge, _1 ) ) ); return 0; }
This compiles in 1.33, but doesn't actually increment the age; the inner
bind returns a temporary int by value, and the outer bind increments that.
Can you please try boost::bind