Sean Kelly Wrote: > Jason House wrote: > > Andrei has stated previously that unique was left out of the type system > > because it added little value to the const system. Now that shared and > > multithreading are here, unique has more value. > > > > I have two basic questions: > > > > 1. What would make unique difficult to add? > > Move semantics. Just passing a unique value type to a function, a copy > is performed.
Why would copying occur? Can't a function simply pass it by reference and then zero out that register when done? > > 2. What benefits do you forsee? > > Message passing could be done without needless copying and with a > reasonable degree of safety. I've done this before in C++ by storing > the reference in a modified shared_ptr (so it can live in containers), > then asserting is_unique() and transferring the reference to an auto_ptr > when passing into the message. Kind of messy, but it works well enough.