|
Boost : |
From: Shunsuke Sogame (mb2act_at_[hidden])
Date: 2006-04-11 08:16:41
David Abrahams wrote:
> Ion Gaztañaga <igaztanaga_at_[hidden]> writes:
>>I would now propose something like:
>>
>>template <class T, class Difference = std::ptrdiff_t>
>>class repeat_read_iterator
>> : public boost::iterator_facade
>> < repeat_read_iterator<T, Difference>
>> , const T
>> , boost::random_access_traversal_tag
>> , const T &
>> , Difference>
>>
>>so dereferencing "repeat_read_iterator<T>" would return const T & with
>>random_access_traversal capability to be able move fast inside that
>>"virtual read-only array". Am I missing something?
>
>
> Only that the library will assign the wrong category unless you do
> something to prevent it.
>
>
>>Do you see this read only repeated sequence simulation useful to
>>include it the iterator library?
>
>
> Sure. But useful enough? That I do not know.
I think the iterator is related to Boost.MPL's 'single_view'.
In the context of iterators, it is maybe 'single_range',
which is the iterator pair of (&x, &x + 1).
I said the iterator could be more generalized by changing the
parameter to a range:
if (equals(make_repeat_range(make_single_range('x'), 6), std::string("xxxxxx")))
{...
if (equals(make_repeat_range(std::string("xxx"), 2), std::string("xxxxxx")))
{...
Using nicer syntax:
if (equals( std::string("xxx")|repeated(2)|jointed(std::string("yy")),
std::string("xxxxxxyy") )
{...
That iterator seems to raise yet another regex/xpressive? :-)
(though I'm not sure it is legal.)
-- Shunsuke Sogame
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk