On 6/2/13 2:43 PM, monarch_dodra wrote:
I think I just had a good idea. First, we introduce "cached": cached
will take the result of front, but only evaluate it once. This is a good
idea in and out of itself, and should take the place of ".array()" in
UFCS chains.

Yah, cached() (better cache()?) should be nice. It may also offer lookahead, e.g. cache(5) would offer a non-standard lookahead(size_t n) up to 5 elements ahead.

 From there, "tee", is nothing more than "calls funs on the front
element every time front is called, then returns front".

 From there, users can user either of:

MyRange.tee!foo(): This calls foo on every front element, and several
times is front gets called several times.
MyRange.tee!foo().cached(): This calls foo on every front element, but
only once, and guaranteed at least once, if it gets iterated.

I kinda dislike that tee() is hardly useful without cache.


Andrei

Reply via email to