range and algorithm-related stuff

Sergey Gromov snake.scaly at gmail.com
Sun Jan 25 06:01:13 PST 2009


Sat, 24 Jan 2009 17:09:07 -0800, Andrei Alexandrescu wrote:

> I'm working on the new range stuff and the range-based algorithm. In all 
> likelihood, you all might be pleased with the results.
> 
> I wanted to gauge opinions on a couple of issues. One is, should the 
> empty() member function for ranges be const? On the face of it it 
> should, but I don't want that to be a hindrance. I presume non-const 
> empty might be necessary sometimes, e.g. figuring out if a stream is 
> empty effectively means fetching an element off it.

I have a hard time imagining a use for a const range.  They're supposed
to be structs, right?  Const value argument is not a very useful idiom.
Also you cannot do much with a const range.

OTOH you never know what downs will invent next time.  Supporting const
transparency as much as possible seems to be the right solution.



More information about the Digitalmars-d mailing list