Thread overview | ||||||
---|---|---|---|---|---|---|
|
October 10, 2014 [Issue 5325] Mutable references to const/immutable/shared classes | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=5325 --- Comment #6 from Martin Nowak <code@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 -- |
October 10, 2014 [Issue 5325] Mutable references to const/immutable/shared classes | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=5325 --- Comment #7 from Michel Fortin <michel.fortin@michelf.com> --- (In reply to Martin Nowak from comment #6) > 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 A storage class will also not work for templates. For instance: Container!(const(Object)) c; // container of const references to const objects Container!(const(Object)ref) c; // container of mutable references to const objects A storage class will not work with the various facilities to manage qualifiers: Unqual!(const(Object)) // should give you const(Object)ref A storage class will not work with pointers (similar case to array): const(Object)ref object; auto ptr = &object; // type is const(Object)ref* *ptr = new Object; // works! Putting this in a storage class will work in a handful of cases (those you can already solve with Rebindable), but it does not play well with anything written to be generic. -- |
May 22, 2018 [Issue 5325] Mutable references to const/immutable/shared classes | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=5325 Dmitry Olshansky <dmitry.olsh@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dmitry.olsh@gmail.com -- |
December 17, 2022 [Issue 5325] Mutable references to const/immutable/shared classes | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=5325 Iain Buclaw <ibuclaw@gdcproject.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Priority|P2 |P4 -- |
Copyright © 1999-2021 by the D Language Foundation