www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21638] New: std.typecons.Refcounted!(T,

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

          Issue ID: 21638
           Summary: std.typecons.Refcounted!(T,
                    RefCountedAutoInitialize.no) should still work when
                    T.this() is annotated with  disable
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: n8sh.secondary hotmail.com

Sample code:

---
void main()
{
    import std.typecons : RefCounted, RefCountedAutoInitialize;

    static struct NoDefaultCtor
    {
         disable this();
        this(int x) { this.x = x; }
        int x;
    }
    auto rc = RefCounted!(NoDefaultCtor, RefCountedAutoInitialize.no)(5);
    assert(rc.x == 5);
}
---

Currently fails to compile with:

[...]/src/phobos/std/conv.d(4488): Error: static assert:  "Cannot emplace a
NoDefaultCtor because NoDefaultCtor.this() is annotated with  disable."

--
Feb 15 2021