std.algorithm move() struct emptying

Stanislav Blinov stanislav.blinov at gmail.com
Mon Aug 30 12:42:40 PDT 2010


Torarin wrote:

 >> T.init cannot be set. It's a fixed value. When you use it, you're 
typically going
 >> to be copying it to an lvalue or creating a temporary. Temporaries 
aren't
 >> lvalues. So, T.init can be assigned to an lvalue, but it isn't 
itself an lvalue.
 >>
 >> - Jonathan M Davis
 >>

> Currently you can take its address, so doesn't that mean that it's an lvalue?

No, you can't. Generally, that is.

For example:

enum A
{
	a,
	b
}

void main()
{
	void* p = &A.init; // won't compile
}

You may be able to take address of what .init returns, but what Andrei 
meant by 'it is not guaranteed' means that this is not always the case. 
So basically, you should not rely on the cases when you can do that.

That's why I was wrong, also. The case wasn't about temporaries at all :)


More information about the Digitalmars-d mailing list