std.algorithm move() struct emptying

Michel Fortin michel.fortin at michelf.com
Tue Aug 31 05:49:24 PDT 2010


On 2010-08-31 06:16:17 -0400, bearophile <bearophileHUGS at lycos.com> said:

> If in generic code T.init is not guaranteed to be an lvalue, as your 
> example shows, isn't it better to disallow (turning it into a syntax 
> error) &T.init in all cases?

Personally, I'd say the code should check if T.init is an lvalue using 
__traits(compiles, &T.init) or is(typeof(&T.init)) and avoid creating a 
static variable or temporary when it is. This optimization of course 
depends &T.init not being a syntax error.

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/



More information about the Digitalmars-d mailing list