[Issue 17251] New: Appender.put errors out with const input range elements

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Mar 10 09:42:48 PST 2017


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

          Issue ID: 17251
           Summary: Appender.put errors out with const input range
                    elements
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: sludwig at outerproduct.org

The following snippet:
---
import std.array : appender;
static struct R {
    int front() const { return 0; }
    bool empty() const { return true; }
    void popFront() {}
}
auto app = appender!(R[]);
const(R)[1] r;
app.put(r[0]);
app.put(r[]);
---

Results in:
---
Error: std.array.Appender!(R[]).Appender.put called with argument types
(const(R)) matches both:
array.d(2821,10):    
std.array.Appender!(R[]).Appender.put!(const(R)).put(const(R) item)
and:
array.d(2849,10):    
std.array.Appender!(R[]).Appender.put!(const(R)).put(const(R) items)
Error: template std.array.Appender!(R[]).Appender.put cannot deduce function
from argument types !()(const(R)[]), candidates are:
array.d(2821,10):        std.array.Appender!(R[]).Appender.put(U)(U item) if
(canPutItem!U)
array.d(2849,10):        std.array.Appender!(R[]).Appender.put(Range)(Range
items) if (canPutConstRange!Range)
array.d(2858,10):        std.array.Appender!(R[]).Appender.put(Range)(Range
items) if (canPutRange!Range)
---

Putting non-const items on the other hand works fine.

--


More information about the Digitalmars-d-bugs mailing list