cast expressions

Dom DiSc dominikus at scherkl.de
Wed May 3 09:03:38 UTC 2023


Sometimes I'm unsure what exactly is the difference between

a)   cast(t)x
b)   (t)x
c)   t(x)

I know, (c) is a constructor call, but for basic types that's the 
same as (a) isn't it?
If t provides a constructor for typeof(x) and x provides opCast 
to type t, which one is called?
Does it depend on the form (a), (b), or (c)?
Does all three forms work if only the constructor or only the 
opCast is provided?
And is (b) always equivalent to (a)? (there is an odd example in 
the grammar where this is not the case)


More information about the Digitalmars-d-learn mailing list