HiveBrain v1.2.0
Get Started
← Back to all entries
patterncppCritical

C++ equivalent of StringBuffer/StringBuilder?

Submitted by: @import:stackoverflow-api··
0
Viewed 0 times
stringbufferequivalentstringbuilder

Problem

Is there a C++ Standard Template Library class that provides efficient string concatenation functionality, similar to C#'s StringBuilder or Java's StringBuffer?

Solution

The C++ way would be to use std::stringstream or just plain string concatenations. C++ strings are mutable so the performance considerations of concatenation are less of a concern.

with regards to formatting, you can do all the same formatting on a stream, but in a different way, similar to cout. or you can use a strongly typed functor which encapsulates this and provides a String.Format like interface e.g. boost::format

Context

Stack Overflow Q#2462951, score: 223

Revisions (0)

No revisions yet.