std::ostringstream wrapper. More...
#include <formatter.hpp>
Public Member Functions | |
formatter () | |
template<typename T > | |
formatter & | operator<< (const T &o) |
std::string | str () |
Private Attributes | |
std::ostringstream | stream_ |
std::ostringstream wrapper.
ostringstream's operator<< doesn't return a ostringstream&. It returns an ostream& instead. This is unfortunate, because it means that you can't do something like this: (ostringstream() << n).str() to convert an integer to a string, all in one line instead you have to use this far more tedious approach: ostringstream s; s << n; s.str(); This class corrects this shortcoming, allowing something like this: string result = (formatter() << "blah " << n << x << " blah").str();
Definition at line 32 of file formatter.hpp.
|
inline |
Definition at line 35 of file formatter.hpp.
|
inline |
Definition at line 41 of file formatter.hpp.
References stream_.
|
inline |
Definition at line 46 of file formatter.hpp.
References stream_.
|
private |
Definition at line 51 of file formatter.hpp.
Referenced by operator<<(), and str().