On 13.04.2012 2:21, Andrei Alexandrescu wrote:
On 4/12/12 5:16 PM, Dmitry Olshansky wrote:
void swap(T)(T lhs, T rhs){
static assert(false, "swap of rvalues has no effect");
}

void swap(T)(ref T lhs, ref T rhs);
{
... //same trustworthy swap
}

I'm not sure how well this scales. We're adding as much boilerplate as functionality here.


To clarify my stance on this somewhat - I believe it just shows 2 things:
a) Sealed conatiners with rvalue returns are rapidly becoming extinct beasts with this new ref-binds-rvalues rule. It arguably might be viewed as an antipattern like declaring C++ operator[] returning non-ref where you obviously didn't meant it. b) Apparently the whole trend of "I don't care if this an rvalue or lvalue" comes to a stop as it turns out that you do care in a lot of cases.

--
Dmitry Olshansky

_______________________________________________
dmd-beta mailing list
[email protected]
http://lists.puremagic.com/mailman/listinfo/dmd-beta

Reply via email to