Boost logo

Boost :

Subject: Re: [boost] [gsoc] Request Feedback for Boost.Ustr Unicode String Adapter
From: Phil Endecott (spam_from_boost_dev_at_[hidden])
Date: 2011-08-15 12:24:05


Soares Chen Ruo Fei wrote:
> I think it'll be easier to just remove the
> decrement function completely.

No, don't do that. (That would be like removing random access from
std::vector because std::list can't implement it efficiently.)

I'm not familiar with the algorithms requiring bidirectional access
that Artyom mentions, but a standard way to make them work with
iterators for various different encodings would be to specialise the
algorithms. You would have a main implementation that requires the
bidirectional (or random access) iterator, and a forwarding
implementation that looks like this:

template <typename FORWARD_ITER>
void algorithm(FORWARD_ITER begin, FORWARD_ITER end)
{
   // Make a copy of the range into a bidirectional container:
   std::vector< typename FORWARD_ITER::value_type > v(begin,end);
   // Call the other specialisation:
   algorithm(v.begin(),v.end());
}

That is the standard time-vs-space complexity trade-off.

> (Actually it's also because I don't know if there is any way to
> conditionally let the code point iterator inherit from either
> std::forward_iterator or std::bidirectional_iterator)

You don't mean "inherit from". You mean "be a model of". See Artyom's
"VERY BAD DESIGN" post. There should not be any virtual methods
anywhere in this library. If you don't understand how that can be
done, we should discuss that urgently.

Phil.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk