Boost logo

Boost :

From: Pavol Droba (droba_at_[hidden])
Date: 2005-05-11 12:45:35

On Wed, May 11, 2005 at 11:38:24AM -0400, David Abrahams wrote:
> Pavol Droba <droba_at_[hidden]> writes:
> > On Wed, May 11, 2005 at 08:59:59AM -0400, David Abrahams wrote:
> >> Pavol Droba <droba_at_[hidden]> writes:
> >>
> >> >
> >> > However I can see a way how to resolve a problem with future unicode
> >> > character classes. Simple trait class can do the job nicely.
> >>
> >> The way to handle this is with a simple range wrapper:
> >>
> >> string_literal("Hello, world")
> >
> > This is what I have actualy suggested in later posts.
> I'm confused, then. When I read

My proposal was here:

Let's try another approach then. It is possible to create an adaptor,
that will create an iterator_range out of a problematic range.

So if you instead of direclty passing the value, you will encapsulate it first
and pass it like this:

char[] ch={'h', 'e', 'l', 'l', 'o', 0 ,'b', 'y', 'e'};

array(str) // array like approach -> result [hello\0bye]
str(ch) // string like approach -> result [hello]

Advantage of this is that it leave open most of the future possibilities,
disadvantage is that it requires more writting. However, this conversion
can be hidden inside the library function, if its intention is unambigous.

Having this facility at hand we can decide what will be default for the plain range.
I'm in favor of the current approach since it is used more frequently IMHO.

First, the adaptors should be natural part of Boost.Range library, since only
Range library is the interface to a container/range that a library uses.

Idea is that a user will always be able to choose his prefered type, while library
writes will be able to define default, that better suits the usage of the library.

For example, a string algorithm would look like:

template<typename RangeT>
... AnAlgorithm(const RangeT& aRange)
   boost::sub_range<RangeT> StrRange=str(aRange);

   // Do something with StrRange

while binary processing algorithm would use 'array' construct.

Imporant aspect is, that neither of 'str' or 'array' constucts should change a type
if one of them is already applied.

Regardles of what default will range provide, user will always be able to select
what he/she wants.

So what about this?


Boost list run by bdawes at, gregod at, cpdaniel at, john at