Boost logo

Boost Users :

Subject: Re: [Boost-users] [string algorithms] trim, functors
From: Pavol Droba (droba_at_[hidden])
Date: 2010-04-11 15:02:26


Hi,

On 11. 4. 2010 19:40, Mathias Gaunard wrote:
> Gaydov Victor a écrit :
>> Hello. Could you answer these two questions:
>>
>> 1. Are there trim range algorithms that work with iterators, instead of
>> strings? (I didn't find such). If not, why not to add them? Something
>> like this: http://pastebin.org/146696
>
> You found it yourself: boost::algorithm::detail::trim_end
> I suppose it could become first-class, but there are better solutions,
> like taking a range and returning a subrange.
>

sub_range was not at hand at the time of writting. I had an idea about to make
a kind of trim - finder, but it didn't made into the real implementation.

>> 2. How can I use, for example, boost::algorithm::is_space() with
>> standard functors? This:
>>
>> boost::not1(boost::algorithm::is_space())
>>
>> doesn't work.
>

You are trying to mix apples with oranges. classification predicates in StringAlgo
library are not compatible with standard stl functors, because they have templated operator.
This is very useful, since you don't have to provide explicit type when passing to an algorithm.

The library provides a set of basic combinators. You can simply write (!boost::is_space() ||
boost::is_digit). Just check the documentation.

In addition you can use boost::lambda tools. All classification predicates are compatible with it.

Best Regards,
Pavol.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net