www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22511] New: Nullable is not copyable when templated type has

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

          Issue ID: 22511
           Summary: Nullable is not copyable when templated type has
                    elaborate copy ctor
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: omerfirmak gmail.com

import std;

struct S
{
        int b;

    this (int b)
    {
        this.b = b;
    }

     disable this(this);
    this (scope ref inout S) inout
    {
        this.b = b;
    }
} 

void main()
{
        Nullable!S _s;
        _s = S(3);
}

-----------------

fails with 

/home/omer/dlang/ldc-1.28.0/bin/../import/std/typecons.d(3031): Error:
Generating an `inout` copy constructor for `struct
std.typecons.Nullable!(S).Nullable` failed, therefore instances of it are
uncopyable
newtest.d(22): Error: template instance
`std.typecons.Nullable!(S).Nullable.opAssign!()` error instantiating

--
Nov 14 2021