[future] Confused about the represents in Doc "boost::future"
Hi all : I got confused in Doc of boost :: futures and I can't got the point of sort of terms. The represents in Overvies of Futures like " Instances can be freely copied and assigned, and boost::shared_future<R>::get() returns a non const reference so that multiple calls to boost::shared_future<R>::get() are safe." no doubt that a const reference .... are safe. a non const reference could be changed by external stimuli. isn't ? Or the key is "Instances can be freely copied" , so that we can say "are safe"? Cheer~ Martin
On Sunday, February 15, 2015 11:55 AM, Cheng Mo wrote:
Hi all : I got confused in Doc of boost :: futures and I can't got the point of sort of terms. The represents in Overvies of Futures like " Instances can be freely copied and assigned, and|boost::shared_future<R>::get()| http://www.boost.org/doc/libs/1_57_0/doc/html/thread/synchronization.html#th...returns a non|const|reference so that multiple calls to|boost::shared_future<R>::get()| http://www.boost.org/doc/libs/1_57_0/doc/html/thread/synchronization.html#th...are safe." no doubt that a const reference .... are safe. a non const reference could be changed by external stimuli. isn't ? Or the key is "Instances can be freely copied" , so that we can say "are safe"?
If you click on that link it says: "shared_future<R>::get() returns a const reference to the value stored in the shared state" It's a typo, it should be const&, the contained value is not copied when the shared_future is copied. Ben
Hi Ben Thanks for the replying. But it's seems like I didn't push my problem clearly . Let me make it simpler. how a non const reference of a value can guarantee multipe calls are safe ? e.g : first call return value like: string &first_ret = fun(); second call return value like: string &second_ret = fun(); because both "first_ret" and "second_ret" are not copy of the fun() return value, they are the right current value. so that we can say these calls are "safe" ? Martin From: Ben Pope Date: 2015-02-16 00:03 To: boost-users Subject: Re: [Boost-users] [future] Confused about the represents in Doc "boost::future" On Sunday, February 15, 2015 11:55 AM, Cheng Mo wrote:
Hi all : I got confused in Doc of boost :: futures and I can't got the point of sort of terms. The represents in Overvies of Futures like " Instances can be freely copied and assigned, and|boost::shared_future<R>::get()| http://www.boost.org/doc/libs/1_57_0/doc/html/thread/synchronization.html#th...returns a non|const|reference so that multiple calls to|boost::shared_future<R>::get()| http://www.boost.org/doc/libs/1_57_0/doc/html/thread/synchronization.html#th...are safe." no doubt that a const reference .... are safe. a non const reference could be changed by external stimuli. isn't ? Or the key is "Instances can be freely copied" , so that we can say "are safe"?
If you click on that link it says: "shared_future<R>::get() returns a const reference to the value stored in the shared state" It's a typo, it should be const&, the contained value is not copied when the shared_future is copied. Ben _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
The part of the doc that says non-const& is wrong. Elsewhere it says const&, which is correct. Ben On Monday, February 16, 2015 09:14 AM, chmhou@sina.com wrote:
Hi Ben Thanks for the replying.
But it's seems like I didn't push my problem clearly . Let me make it simpler. how a non const reference of a value can guarantee multipe calls are safe ? e.g : first call return value like: string &first_ret = fun();
second call return value like:
string &second_ret = fun();
because both "first_ret" and "second_ret" are not copy of the fun() return value, they are the right current value. so that we can say these calls are "safe" ? ------------------------------------------------------------------------ Martin
*From:* Ben Pope mailto:benpope81@gmail.com *Date:* 2015-02-16 00:03 *To:* boost-users mailto:boost-users@lists.boost.org *Subject:* Re: [Boost-users] [future] Confused about the represents in Doc "boost::future" On Sunday, February 15, 2015 11:55 AM, Cheng Mo wrote: > Hi all : > I got confused in Doc of boost :: futures and I can't got the point of > sort of terms. > The represents in Overvies of Futures like > " Instances can be freely copied and assigned, > and|boost::shared_future<R>::get()| > http://www.boost.org/doc/libs/1_57_0/doc/html/thread/synchronization.html#th...returns > a non|const|reference so that multiple calls > to|boost::shared_future<R>::get()| > http://www.boost.org/doc/libs/1_57_0/doc/html/thread/synchronization..html#t...are > safe." > no doubt that a const reference ..... are safe. > a non const reference could be changed by external stimuli. isn't ? > Or the key is "Instances can be freely copied" , so that we can say "are > safe"? If you click on that link it says: "shared_future<R>::get() returns a const reference to the value stored in the shared state" It's a typo, it should be const&, the contained value is not copied when the shared_future is copied. Ben _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Ok , I got the point , Thanks a lot Martin From: Ben Pope Date: 2015-02-16 09:36 To: boost-users Subject: Re: [Boost-users] [future] Confused about the represents in Doc "boost::future" The part of the doc that says non-const& is wrong. Elsewhere it says const&, which is correct. Ben On Monday, February 16, 2015 09:14 AM, chmhou@sina.com wrote:
Hi Ben Thanks for the replying.
But it's seems like I didn't push my problem clearly . Let me make it simpler. how a non const reference of a value can guarantee multipe calls are safe ? e.g : first call return value like: string &first_ret = fun();
second call return value like:
string &second_ret = fun();
because both "first_ret" and "second_ret" are not copy of the fun() return value, they are the right current value. so that we can say these calls are "safe" ? ------------------------------------------------------------------------ Martin
*From:* Ben Pope mailto:benpope81@gmail.com *Date:* 2015-02-16 00:03 *To:* boost-users mailto:boost-users@lists.boost.org *Subject:* Re: [Boost-users] [future] Confused about the represents in Doc "boost::future" On Sunday, February 15, 2015 11:55 AM, Cheng Mo wrote: > Hi all : > I got confused in Doc of boost :: futures and I can't got the point of > sort of terms. > The represents in Overvies of Futures like > " Instances can be freely copied and assigned, > and|boost::shared_future<R>::get()| > http://www.boost.org/doc/libs/1_57_0/doc/html/thread/synchronization.html#th...returns > a non|const|reference so that multiple calls > to|boost::shared_future<R>::get()| > http://www.boost.org/doc/libs/1_57_0/doc/html/thread/synchronization..html#t...are > safe." > no doubt that a const reference ..... are safe. > a non const reference could be changed by external stimuli. isn't ? > Or the key is "Instances can be freely copied" , so that we can say "are > safe"? If you click on that link it says: "shared_future<R>::get() returns a const reference to the value stored in the shared state" It's a typo, it should be const&, the contained value is not copied when the shared_future is copied. Ben _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
On Monday, February 16, 2015 04:34 PM, Vicente J. Botet Escriba wrote:
Le 16/02/15 02:36, Ben Pope a écrit :
The part of the doc that says non-const& is wrong.
Elsewhere it says const&, which is correct.
Hi,
please could you point me where in the doc it is sais non-const?
http://www.boost.org/doc/libs/1_57_0/doc/html/thread/synchronization.html#th... 4th paragraph. Ben
source url : http://www.boost.org/doc/libs/1_57_0/doc/html/thread/synchronization.html#th... Futures Overview The 4th section say that "Instances can be freely copied and assigned, and boost::shared_future<R>::get() returns a non const reference so that multiple calls to boost::shared_future<R>::get() are safe." That's just what I am confused about. Is it one typo ? Martin From: Vicente J. Botet Escriba Date: 2015-02-16 16:34 To: boost-users Subject: Re: [Boost-users] [future] Confused about the represents in Doc "boost::future" Le 16/02/15 02:36, Ben Pope a écrit :
The part of the doc that says non-const& is wrong.
Elsewhere it says const&, which is correct.
Hi, please could you point me where in the doc it is sais non-const? Thanks, Vicente _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Le 16/02/15 09:46, chmhou@sina.com a écrit :
source url : http://www.boost.org/doc/libs/1_57_0/doc/html/thread/synchronization.html#th...
Futures
Overview
The 4th section say that "Instances can be freely copied and assigned, and |boost::shared_future<R>::get()| http://www.boost.org/doc/libs/1_57_0/doc/html/thread/synchronization.html#th... returns a non |const| reference so that multiple calls to |boost::shared_future<R>::get()| http://www.boost.org/doc/libs/1_57_0/doc/html/thread/synchronization.html#th... are safe."
That's just what I am confused about. Is it one typo ?
Yes. Fixed on develop branch. Thanks, Vicente
participants (4)
-
Ben Pope
-
Cheng Mo
-
chmhou@sina.com
-
Vicente J. Botet Escriba