Why do "const inout" and "const inout shared" exist?
Stefan Koch via Digitalmars-d
digitalmars-d at puremagic.com
Sat Jul 1 15:26:28 PDT 2017
On Saturday, 1 July 2017 at 22:16:12 UTC, Timon Gehr wrote:
>
> struct S{
> int x;
> ref inout(int) foo()inout{
> return x;
> }
> }
>
> void main(){
> S s;
> s.foo()++; // ok!
> const(S) t = s;
> import std.stdio;
> writeln(t.foo());
> // t.foo()++; // error
> }
Oh damn. I was not aware that it could behave non-constly.
since when does it do that ?
More information about the Digitalmars-d
mailing list