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

Tomáš Chaloupka <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|critical                    |normal

--- Comment #1 from Tomáš Chaloupka <[email protected]> ---
I've found possible workaround.

```
auto ref unwrap(EX)(auto ref EX res) {
    static if (__traits(isRef, res)) {
        printf("unwrap(ref)\n");
        return res.get();
    } else {
        printf("unwrap(val)\n");
        auto ret = res.get().move(); // < NRVO
        return ret;
    }
}
```

Then with `Foo f = gen(42).unwrap;`

It otputs:
```
~this(0)
~this(0)
~this(0)
unwrap(val)
~this(0)
~this(42)
```

But I'm still puzzled about what's wrong with the original one.

--

Reply via email to