|
Boost : |
From: Shunsuke Sogame (mb2act_at_[hidden])
Date: 2006-04-09 20:41:06
David Abrahams wrote:
> Ion Gaztañaga <igaztanaga_at_[hidden]> writes:
>
>
>>>You haven't really explained what this thing is supposed to be doing.
>>>As far as I can tell from the code, it dereferences to the same
>>>location at each position. If that's really what you intend, you
>>>ought to do something to ensure that its iterator category doesn't
>>>indicate it satisfies forward iterator requirements.
>>
>>A pair of "range_from_ref_iterator" simulates a pair of random access
>>iterators that point to an array of N identical values.
>
>
> It's not a legal random access (or even forward) iterator if it
> visits the same *element* more than once in a traversal. That's why I
> said the above about the iterator category.
>
>
>>>Seems like a reasonable idea, but I'm not sure whether it's useful
>>>enough to be included. I'd definitely call it something other than
>>>range_from_ref_iterator, though. constant_iterator or something like
>>>that seems appropriate.
>>
>>constant_iterator seems good,
>
>
> Whoops, "constant iterator" is already overloaded with a different
> meaning. Something else, maybe... "repeat iterator?"
I agree it is nice to have "verb" for 'range adaptors'.
copy(x|repeated(10)|transformed..., outIter);
repeat_range(repeat_iterator pair) seems to make an object be a range:
copy(x|repeated(1), outIter);
So generalized!
But as Mr.Abrahams pointed, it is pity repeat_iterator for now is
illegal. (I remember I wrote the same code as Mr.Gaztanaga's!)
Is it possible it can have a legal implementation? I don't know for sure...
-- Shunsuke Sogame
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk