cast()x - a valid expression?
Andrej Mitrovic
andrej.mitrovich at gmail.com
Wed Jun 1 12:38:32 PDT 2011
It seems to do even more than that:
int a;
const int b;
immutable int c;
shared int d;
shared(const int) e;
static assert(is(typeof(cast()a) == int));
static assert(is(typeof(cast()b) == int));
static assert(is(typeof(cast()c) == int));
static assert(is(typeof(cast()d) == int));
static assert(is(typeof(cast()e) == int));
Talk about stealing the storm from std.traits.Unqual..
On 6/1/11, KennyTM~ <kennytm at gmail.com> wrote:
> While checking the Phobos source I've found an interesting expression
>
> cast()(result[i]) = to!(E)(e);
>
> The 'cast()' means 'cast to mutable', e.g.
>
> class S {}
> void g(S x) {}
> void main() {
> const S s;
> g(cast()s);
> }
>
> But this is not documented in the D spec (CastParam cannot be empty). Is
> this an "accept-invalid" bug, or just a feature not yet documented?
>
>
More information about the Digitalmars-d
mailing list