[Issue 11307] Make const(T).init and immutable(T).init lvalues
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sun Apr 27 23:58:42 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=11307
monarchdodra at gmail.com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |WONTFIX
--- Comment #4 from monarchdodra at gmail.com ---
(In reply to Kenji Hara from comment #3)
> (In reply to monarchdodra from comment #0)
> > ".init" is a global property, that is marked as rvalue, to prevent it being
> > modified. This is correct behavior.
> >
> > However, when "T" is const/immutable already, then it is illegal to modify
> > it anyways. Making ".init" an lvalue for such cases has advantages.
>
> Not only to prevent its modification, T.init makes an rvalue to prevent copy
> construction on its usage.
>
> auto t = T.init;
>
> If T.init returns an lvalue, initializing t will always invoke T's postblit
> if exists.
I think that's good enough of a reason to not implement this.
--
More information about the Digitalmars-d-bugs
mailing list