[Issue 19749] Inout causes wrong type inference

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Mar 18 12:36:41 UTC 2019


https://issues.dlang.org/show_bug.cgi?id=19749

anonymous4 <dfj1esp02 at sneakemail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Hardware|x86                         |All
                 OS|Mac OS X                    |All

--- Comment #2 from anonymous4 <dfj1esp02 at sneakemail.com> ---
Well, that's how inout works.
Simple inference does what you want:

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-bugs mailing list