[Issue 5325] Mutable references to const/immutable/shared classes
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Fri Oct 10 07:48:39 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=5325
--- Comment #6 from Martin Nowak <code at dawg.eu> ---
(In reply to Michel Fortin from comment #3)
> That'll only work in the context where you're declaring a tail-const
> variable of type Object. If you're declaring an array of tail-const objects,
> or passing a tail-const object as a template parameter, you can't omit the
> parenthesis. But the ref postfix works:
>
> const(Object)ref[] arrayOfTailConstObjects;
Still the distinction between const as storage class and const as type
qualifier seems to be a nicer approach than introducing special syntax.
It seems to work for templates parameters
template Foo(T) { pragma(msg, T); }
alias test = Foo!(const Object);
alias test2 = Foo!(const(Object));
True, for array elements you cannot specify a storage class.
const(Object)[] ary; // ary of tail const objects or array of const objects
const(Object[]) cary; // const array of const objects
--
More information about the Digitalmars-d-bugs
mailing list