class OStringStream
Defined at line 65 of file ../../third_party/abseil-cpp/src/absl/strings/internal/ostringstream.h
The same as std::ostringstream but appends to a user-specified std::string,
and is faster. It is ~70% faster to create, ~50% faster to write to, and
completely free to extract the result std::string.
std::string s;
OStringStream strm(
&s
);
strm
<
<
42
<
<
' '
<
<
3.14; // appends to `s`
The stream object doesn't have to be named. Starting from C++11 operator
<
<
works with rvalues of std::ostream.
std::string s;
OStringStream(
&s
)
<
<
42
<
<
' '
<
<
3.14; // appends to `s`
OStringStream is faster to create than std::ostringstream but it's still
relatively slow. Avoid creating multiple streams where a single stream will
do.
Creates unnecessary instances of OStringStream: slow.
std::string s;
OStringStream(
&s
)
<
<
42;
OStringStream(
&s
)
<
<
' ';
OStringStream(
&s
)
<
<
3.14;
Creates a single instance of OStringStream and reuses it: fast.
std::string s;
OStringStream strm(
&s
);
strm
<
<
42;
strm
<
<
' ';
strm
<
<
3.14;
Note: flush() has no effect. No reason to call it.
Public Methods
void OStringStream (std::string * str)
The argument can be null, in which case you'll need to call str(p) with a
non-null argument before you can write to the stream.
The destructor of OStringStream doesn't use the std::string. It's OK to
destroy the std::string before the stream.
Defined at line 72 of file ../../third_party/abseil-cpp/src/absl/strings/internal/ostringstream.h
void OStringStream (OStringStream && that)
Defined at line 74 of file ../../third_party/abseil-cpp/src/absl/strings/internal/ostringstream.h
OStringStream & operator= (OStringStream && that)
Defined at line 79 of file ../../third_party/abseil-cpp/src/absl/strings/internal/ostringstream.h
std::string * str ()
Defined at line 86 of file ../../third_party/abseil-cpp/src/absl/strings/internal/ostringstream.h
const std::string * str ()
Defined at line 87 of file ../../third_party/abseil-cpp/src/absl/strings/internal/ostringstream.h
void str (std::string * str)
Defined at line 88 of file ../../third_party/abseil-cpp/src/absl/strings/internal/ostringstream.h