[Issue 21638] New: std.typecons.Refcounted!(T, RefCountedAutoInitialize.no) should still work when T.this() is annotated with @disable

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Feb 15 19:52:16 UTC 2021


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 at puremagic.com
          Reporter: n8sh.secondary at 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."

--


More information about the Digitalmars-d-bugs mailing list