<div dir="ltr">You should be able to work around this by using `for` loop instead of `foreach`.<br>IMO that's a design bug in `foreach`: <a href="https://issues.dlang.org/show_bug.cgi?id=15413">https://issues.dlang.org/show_bug.cgi?id=15413</a><br><div class="gmail_extra"><br><div class="gmail_quote">2016-09-14 14:39 GMT+02:00 Jerry via Digitalmars-d <span dir="ltr"><<a href="mailto:digitalmars-d@puremagic.com" target="_blank">digitalmars-d@puremagic.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I got a range which disables copy construction and I want to loop the range within another loop using the same range.<br>
So I thought I can mark the struct range with @disable this(this) and then use refRange to initialize the loop.<br>
<br>
So with something like this:<br>
<br>
void main()<br>
{       <br>
        auto valueRange = FooRange("123");<br>
        foreach(ch; refRange(&valueRange))<br>
                writeln(ch);<br>
}<br>
<br>
<br>
struct FooRange {<br>
        @disable this();<br>
        @disable this(this);<br>
        this(string str) {<br>
                this.str = str;<br>
        }<br>
        <br>
        @property bool empty() { return str.empty; }<br>
        @property dchar front() { return str.front; }<br>
        void popFront() { str.popFront; }<br>
        <br>
private:<br>
        string str;<br>
}<br>
<br>
<br>
But I get compile time errors messages saying:<br>
std/range/package.d(8155,23): Error: struct app.FooRange is not copyable because it is annotated with @disable<br>
<br>
It feels strange that refRange ever want to copy.<br>
Bug or feature?<br>
<br>
</blockquote></div><br></div></div>