Boost logo

Boost Users :

From: Rubiphisto (snwcwt_at_[hidden])
Date: 2008-06-10 09:55:24


Thank you for your answer. boost::bind<int&>( &_sUserData::m_nUserAge, _1 ) is work good.
----- Original Message -----
From: "Peter Dimov" <pdimov_at_[hidden]>
Newsgroups: gmane.comp.lib.boost.user
To: <boost-users_at_[hidden]>
Sent: Thursday, June 05, 2008 4:33 AM
Subject: Re: A question about boost::bind function


>> 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<int&>( &_sUserData::m_nUserAge, _1 ) and see
> if it helps?
>
>


--------------------------------------------------------------------------------


> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net