Cast Object - get null

Namespace rswhite4 at googlemail.com
Thu Apr 19 14:17:52 PDT 2012


> T opCast(T : const(Vector2D!U), U)() const
> {
>     return new T(x, y);
> }

Awesome, now i only need this three and it works perfect.

typeof(this) opCast(T)() if 
(isImplicitlyConvertible!(typeof(this), T)) {
	writeln("implicit cast");
	return this;
}

const(typeof(this)) opCast(T)() const if 
(isImplicitlyConvertible!(typeof(this), const T)) {
	writeln("implicit const cast");
	return this;
}

T opCast(T : const(Vector2D!(U)), U)() const {
	writeln("Other cast");
	return T(x, y);
}

Many thanks to you two! :)




More information about the Digitalmars-d-learn mailing list