Why do we have transitive const, again?

Walter Bright newshound2 at digitalmars.com
Sat Sep 24 17:33:59 PDT 2011


On 9/23/2011 6:52 PM, Mehrdad wrote:

> To illustrate, I run into problem almost every other time I use D, and to me
> it's *only* a problem because source is const:
>
> class MyRange : InputRange!char
> {
> char peeked;
> InputRange!char source;
> char front() const

char front()  // fixed!

> {
> // How do I lazy-load the value?
> if (peeked == '\0')
> {
> peeked = source.front;
> // ERROR, popFront isn't const...
> source.popFront();
> }
> return peeked;
> }
> }


More information about the Digitalmars-d mailing list