|
Boost : |
Subject: Re: [boost] [boost-lists][string algo] C++0x string algo.
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2010-01-16 14:20:57
Germán Diago wrote:
> Hello. I'm using c++0x-enabled c++0x compiler.
>
> I was going to use this piece of code:
>
> typedef vector< string > split_vector_type;
> split_vector_type svec;
>
> split(svec, str, is_any_of(":"));
>
> for c++0x, I shouldn't need to define a typedef to take advantage of
> that. I think it would be more idiomatic
> (and way easier to do) to use something like this:
>
> auto splitrange = split(str, is_any_of(":"));
>
> So I would like to know if it's possible to map split to a range
> result by default (not a vector, maybe). And it could also
> be used with a vector if you put it explicitly:
>
> auto splitvec = split<vector<string>>(str, ....);
>
> I think the whole library should be readapted to return by value. I've
> spent some time figuring how to use the library
> because of the out parameters in the arguments.
>
> Can anyone tell me if there is any plan to change this?
There is none.
> Or if it
> should be possible?
It's possible, yes. But that means the splitting would be done lazily as
you iterate the returned range.
I have the basic utilities needed to adapt all StringAlgo algorithms to
behave that way (well, I have a framework for lazy segmentation and
transformation or ranges) if there is interest.
I wouldn't find it ok for split to return a vector<string> since I like
to be kept in control of how I store my elements, and there is no
control without taking the container as an argument or using the method
I just mentioned.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk