safer casts - take II
Joel C. Salomon
joelcsalomon at gmail.com
Wed May 14 08:59:36 PDT 2008
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Yigal Chripun wrote:
> there are there forms of cast:
> (a) cast(T)something
> (b) cast!(T)something
> (c) reinterpret_cast!(T)
So, for example, given the following definitions:
class A {…}
class B : A {…}
class C : A {…}
class D {…}
we can write:
const A ac;
auto a = cast!(A)a;
and:
B b0;
auto a = cast(A)b0;
auto b = cast(B)a; // should succeed
auto c = cast(C)a; // c is null
and:
A a;
auto d = reinterpret_cast(D)a; // legal but unpredictable
Are these all the intended uses?
—Joel S.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFIKwxozLx4GzBL9dYRAlJMAJwIHL+xCS4ZYDk56JOj6yw4LocF/wCffK/e
GSYe5sbxojtr6Ha47jyLP7E=
=/jDq
-----END PGP SIGNATURE-----
More information about the Digitalmars-d
mailing list