View mode: basic / threaded / horizontal-split · Log in · Help
August 31, 2010
Re: std.algorithm move() struct emptying
Stanislav Blinov:

> > 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.

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?

Bye,
bearophile
Top | Discussion index | About this forum | D home