www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 24415] New: only doesn't work with elements that have a copy

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

          Issue ID: 24415
           Summary: only doesn't work with elements that have a copy
                    constructor
           Product: D
           Version: D2
          Hardware: x86_64
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: issues.dlang jmdavisProg.com

This code

---
void main()
{
    import std.range;

    auto a = only(S.init);
    auto b = a;
}

struct S
{
    this(ref return scope inout(S) rhs) scope  safe inout pure nothrow
    {
    }
}
---

results in the error

---
q.d(6): Error: no property `__ctor` for `b` of type `std.range.OnlyResult!(S)`
/usr/local/include/dmd/std/range/package.d(10333):        struct `OnlyResult`
defined here
---

The error seems to stem from the fact that OnlyResult declares a copy
constructor but then makes it private for some reason.

--
Feb 26