On 16/03/2019 04:49, Paul Backus via Digitalmars-d-learn wrote:
On Friday, 15 March 2019 at 23:57:15 UTC, aliak wrote:
Anyone knows how to make this work?

You need an explicit `inout` on the return value of `make`:

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

I think (but may be wrong) that you don't need inout here, since a plain 'ref' will (and does) work. This is accepted by me (I added vars to make the code clearer to myself):

struct S(T) {
    T value = T.init;

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

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

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

Reply via email to