Unqual fails with pointer?

Namespace rswhite4 at googlemail.com
Thu Jun 13 15:11:41 PDT 2013


Just out of interest: how safe is something like this:

----
UnqualPtr!From unqual_cast(From : U*, U)(From from) {
	union Cast {
		From from;
		UnqualPtr!From to;
	}
	
	Cast c;
	c.from = from;
	
	return c.to;
}

const B* cb = ...;
B* b = unqual_cast(cb);
----

compared to this:

----
const B* cb = ...;
B* b = cast(B*) cb;
----

I'm just playing around in favor of something like 'const_cast' 
from C++.


More information about the Digitalmars-d-learn mailing list