Casting Pointers?
Dicebot via Digitalmars-d
digitalmars-d at puremagic.com
Thu May 12 07:40:26 PDT 2016
On Thursday, 12 May 2016 at 14:20:28 UTC, H. S. Teoh wrote:
> Does alias this solve the problem, or it introduces new ones?
void foo ( ref char[] x )
{
static assert (x.sizeof == Wrapper.sizeof);
(cast(Wrapper*) &x).someMethod(); // may resize x
}
Not sure how alias this can be applicable here. One recurring
reason to write code like this is when one replaces plain type
with more type-safe wrapper but wants to keep old API working
with raw arrays as deprecated.
More information about the Digitalmars-d
mailing list