isRvalue trait

Nordlöw via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Oct 10 04:46:01 PDT 2016


At

https://github.com/nordlow/phobos-next/blob/master/src/moval.d

I've implemented a helper function for creating r-value out of 
l-values defined as

E movedToRvalue(E)(ref E e)
{
     import std.algorithm.mutation : move;
     E value;
     move(e, value);             // this can be optimized
     return value;
}

For the case when movedToRvalue is called with an r-value, such 
as in,

     static assert(__traits(compiles, { consume(S(14)); }));

I would like to overload to an identity op.

Is this currently possible somehow? I cannot find any trait 
`isRvalue` that fulfills

     static assert(isRvalue!(S(14)));

Is there one?


More information about the Digitalmars-d-learn mailing list