At the very least, it's contradicted by the website:

http://dlang.org/expression#CastExpression

"Casting a value v to a struct S, when value is not a struct of the
same type, is equivalent to: S(v)"

In your case, you have no 'this' in Decimal to accept a Decimal with
other arguments. This should not work.
Timon provides a nice example:

struct A{
    int a,b;
}
struct B{
    long x;
}

void main(){
    auto a=A();
    auto b=cast(B)a;
}

Here, cast(B)a should be transformed into B(a). AFAICT, this should
not compile, but it does.
  • Casting Structs Paul D Anderson via Digitalmars-d
    • Re: Casting Structs Philippe Sigaud via Digitalmars-d

Reply via email to