Range returning an array
Joseph Rushton Wakeling
joseph.wakeling at webdrake.net
Tue Apr 9 15:09:07 PDT 2013
On 04/09/2013 11:02 PM, Steven Schveighoffer wrote:
> 1. documentation. Make sure the user of the range knows that this data is going
> to be re-used.
In this case it's quite unlikely anyone will ever want to use the code apart
from me, but yes, good point. :-)
> 2. Make front() return const if possible. It is another signal that you aren't
> supposed to keep this data.
> 3. For your specific situation, add lastFront():
It's an interesting thought. I don't think it's ultimately the right way to go
-- yes, my application rests strongly on finding the last value, but the problem
is very simply that popFront kills the value _before_ finding out if the range
is now empty.
The only logical option that I can see is to tweak things so that doesn't
happen, which is possible but probably a little bit more finnicky than the
current implementation.
More information about the Digitalmars-d-learn
mailing list