Can't make inout work.

Kagamin spam at here.lot
Sun Mar 17 17:34:42 UTC 2019


On Saturday, 16 March 2019 at 14:57:35 UTC, Paul Backus wrote:
> This code fails to compile if you change `auto s2` to `const 
> s2`--in other words, it has the same problem as the original 
> example.

Maybe there's not much need for qualifiers anyway.

struct S(T) {
     T value;
}

auto make(T)(ref T value) {
     return S!T(value);
}

auto f(T)(ref T s) {
     return make(s.value);
}

void f() {
     class C {}
     C c;
     auto s1 = S!C(c);
     const s2 = make!C(c);
     auto s3 = f(s2);
}


More information about the Digitalmars-d-learn mailing list