Boost logo

Boost :

From: Phil Nash (phil.nash.lists_at_[hidden])
Date: 2003-10-19 17:07:34

[Gennadiy Rozental]
> May we define trim so that:
> std::string res = trim( orig );
> generate copying algorithm, while
> trim( orig ) generate in place modifying one?

:-o Too subtle and clever! I think this would obscure the behaviour even

FWIW my opinion is that copied is usually safer and mutable is usually an
optimisation. IMHO it therefore follows that copied should be the default
However I would go further and say that the important thing is that both
forms *are* present and there is a consistent and simple naming convention
to distinguish between them. This seems to be satisfied and for me that is
Perhaps one way to resolve this matter is to make both forms explicit and
lose the idea of a "default", eg:

std::string t = trim_copy( s );
trim_inplace( u );

It would at least reduce whatever confusion there might be.

BTW, I have not looked at the whole library in detail but have browsed the
docs. On that basis, and as a fairly regular user of such algorithms in
general, my inclination is to accept this library - either in its current
form, or with whatever modifications arise from this discussion on the
mutating vs copying naming debate.



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