www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Another question about move()

The documentation for std.algorithm.move() says:

* If hasAliasing!T is true, then the representation of source is 
bitwise copied into target and then source = T.init is evaluated.

* Otherwise, target = source is evaluated.

However, current implementation does not in fact check for 
aliasing. Instead, it only checks if T is a struct and has a 
user-defined destructor or copy constructor. Only in this case it 
really "obliterates" the source. For references, nullifying is 
deliberately commented out. It also doesn't handle unions or 
static arrays.

So, here's a question: why is that condition for hasAliasing is 
in requirements? Can move() violate immutability? (e.g., 
following the hasAliasing requirement, wiping out immutable T 
member would be legal, but wiping out immutable(T)* would be not).

Would the complete implementation of move() (accounting for 
references, unions and static arrays) be allowed to wipe out any 
const/immutable members of a moved-from entity?
Jan 28 2014