Boost logo

Boost Users :

Subject: Re: [Boost-users] [future] Confused about the represents in Doc "boost::future"
From: Ben Pope (benpope81_at_[hidden])
Date: 2015-02-15 11:03:44


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#thread.synchronization.futures.reference.shared_future.get>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#thread.synchronization.futures.reference.shared_future.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"?

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 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