|
Boost : |
From: Darren Cook (darren_at_[hidden])
Date: 2003-10-19 19:01:46
The below (*) argument seems convincing, so I think explicitly named
_inplace() functions would be better.
(not had chance to look at the library yet however)
>>> s.trim() is what IMHO would be an intuitive interface to changes s's
>>> state. Sadly, it's not possible to provide it.
A boost::string that derived from std::string and added all the _inplace()
functions would be nice.
Darren
*:
> There is a difference: If you write
>
> trim( s );
>
> [copying version assumed] you expect that 's' is now trimmed. And you
> usually check this as when writing code, you run it to see if it works.
> If it's not trimmed, you look for the reason and it's IMHO not hard to
> find this bug now. But if you write
>
> std::string t = trim( s );
>
> [modifying version assumed], this has the effect you expect, namely 't'
> contains a trimmed version of 's'. The problem is, that this has a side
> effect on 's'. In a larger code base, these side effects sometimes show
> up very late and some of them are really hard to find. Well, of course
> this is just my personal experience.
>
> Regards, Daniel
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk