On Wed, Apr 27, 2016 at 8:02 PM, Ehsan Akhgari <ehsan.akhg...@gmail.com>
wrote:

> Hmm, OK, this is a good example.  :-)
>
> Even though Xidorn's suggestion may work in some cases, I can imagine
> that in other cases you wouldn't want the caller to have to know the
> preconditions of calling TakeMedia.
>
>
I don't really think it's a good example. TakeMediaIfKnown is accepting a
UniquePtr<MediaFile> as an inout parameter: it uses, and may modify, its
value. It should take UniquePtr<MediaFile> &.

UniquePtr.h disagrees with me:

 * ...  To conditionally transfer
 * ownership of a resource into a method, should the method want it, use a
 * |UniquePtr&&| argument.

It looks to me as if C++'s version of move semantics is a spiffy solution
to some gnarly problems with containers, but Rust shows that there's
something much more fundamental going on with moves, which C++'s version
doesn't capture very well.
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to