On 08/01/2014 03:48 AM, Neil wrote:
> Only UniquePtr's own copy and assignment operators should take UniquePtr&&. 
> Other call sites should either take const UniquePtr& (if they will not take 
> ownership of the pointer), UniquePtr& (if they may or may not need to take 
> ownership of the pointer) or UniquePtr (if they will take ownership of the 
> pointer).

Oops, you're largely right.  There are perhaps rare cases where it might make 
sense to accept UniquePtr&&, but it's pretty uncommon.  I somewhat meant to 
elaborate on this in the blog post, then forgot.  Probably I won't bother at 
this point.

But, largely what I would have said is encapsulated in this Stack Overflow 
question/answer:

http://stackoverflow.com/questions/8114276/how-do-i-pass-a-unique-ptr-argument-to-a-constructor-or-a-function

This discussion is much less intricate and technical than the rvalue reference 
series I linked in the post as "subtle", so it's worth a read if you're 
interested and won't take up that much time to digest.  At the same time, it's 
largely an expansion of what NeilAway said, so feel free not to read it if you 
read his post.  :-)

Jeff
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to