On Thursday, 11 February 2016 at 14:25:39 UTC, Atila Neves wrote:
D has move semantics. Deep copies are done with post-blit. Fair
enough if you just:
auto foo = bar;
Then it's a shallow copy. The only difference to a "true" move
is that bar isn't T.init, but that's easily done with the move
function (assuming the struct has a destructor) or manually.
*blank stare*
C++:
void foo(Foo); //copy
void foo(Foo&); //by-ref, only lvalues
void foo(Foo&&); //move, only rvalues
In modern generics-oriented C++ I would say:
void foo(T); // by value - and probably not what you want
void foo(const T&) // copy semantics overload
void foo(T&&) // move semantics overload
Please keep in mind that C++ do perfect forwarding of those
rvalue references when you pass it down a call chain.