Boost logo

Boost :

From: Gennadiy Rozental (gennadiy.rozental_at_[hidden])
Date: 2006-01-30 20:06:24


>> An alternative is having std::string somewhere cashed.
>
> ??
>
>> But we a) may not place for it b) still do not want to depend on
>> performance on dynamic clear/resize methods.
>
> I don't understand.

Let's see. Here is frequently called function:

..
if( ... ) {
   // here we need string to format a message
}

...

if( ... ) {
   // here we need string to format a message again
}

stack_string you could just put inside each if branch. No need to care that
it gets destroyed. With any string that employ dynamic allocation one might
find it wasteful. So usually we are trying to reuse the same variable,
right? Now where do we put it? If this is member function we could put in
class body, which may or may not be convenient. Or we could make it static.
But then clear/resize methods for string should be efficient and not include
and memory deallocation. And MT could be an issue.

This is the case I was talking about.

Gennadiy


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