Boost logo

Boost :

From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2003-10-22 20:19:18


From: "Ross MacGregor" <ross__macgregor_at_[hidden]>

>
> Firingme wrote:
> > Can we give some suffix after trim ?
> > Just as:
> >
> > 1
> > std::string res = trim_copyto(orig) ;
> > 2
> > void trim(std::string) ;
> > 3
> > std::string& trim_chain(std::string) ;
>
> I think this is the best solution yet.
>
> 1) The often used inplace operation is short and sweet, matches STL
> syntax for mutating algorithms, and is guarded from assignment.
>
> 2) Other less often used but useful variants are explicit.
>
> How can you argue against that?
>

we're trying to guard our selves from a algorithm explosion problem. Having
separate _chain
variants makes it worse. As Peter Dimov said, you can easily make a function
that does the same.
Even some of the copy variants could be remoevd, since the string must be
copy-constructible, so the
user can just copy it by himself and then apply the mutating algorithm (I do
think the copy versions are ok).

As for the chaining, then maybe we need some device that allows of to call n
function operation on eachother's result:

string s:
chain( &trim, &to_upper, s );

?

Thorsten


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