class GetStreamString { # Nothing to see here. # Just a type to allow us to define the below operator. }; const char* operator<<( std::ostream& ostr, const GetStreamString& ) { return dynamic_cast< std::stringstream& >( ostr ).str().c_str(); }