Hi,

About this issue in Phobos:
https://issues.dlang.org/show_bug.cgi?id=21216
SortedRange.empty should be const, .front should be inout

Just adding const/inout to SortedRange's methods won't be enough; if we add const/inout here, then many other Phobos ranges need to become const/inout-correct to keep the tests passing. Before I dive deeper into annotating their methods, I would like to verify my assumptions on how template function attribute deduction works:

1) I know that templated functions deduce their own attributes on instantiation. But front()/empty() are non-templated methods within the templated struct SortedRange. Will attribute deduction happen here?

2) Is it sensible/possible to force attribute deduction by declaring empty() in SortedRange as a zero-argument template? I.e.:
    @property bool empty()() { return this._input.empty; }

3) Should I rather annotate the non-templated SortedRange.empty/.front manually? But with what, then? empty() should probably be const, but it's never @nogc if annotated manually, even if the wrapped range offers empty() @nogc.

-- Simon

Reply via email to