Allow explicitly setting ReusableStringStream's serialized data

This commit is contained in:
Martin Hořeňovský 2020-08-02 18:50:56 +02:00
parent a4ac07d104
commit 9d591f19ff
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A
2 changed files with 9 additions and 2 deletions

View File

@ -173,10 +173,14 @@ namespace Detail {
Singleton<StringStreams>::getMutable().release( m_index );
}
auto ReusableStringStream::str() const -> std::string {
std::string ReusableStringStream::str() const {
return static_cast<std::ostringstream*>( m_oss )->str();
}
void ReusableStringStream::str( std::string const& str ) {
static_cast<std::ostringstream*>( m_oss )->str( str );
}
///////////////////////////////////////////////////////////////////////////

View File

@ -37,7 +37,10 @@ namespace Catch {
ReusableStringStream();
~ReusableStringStream();
auto str() const -> std::string;
//! Returns the serialized state
std::string str() const;
//! Sets internal state to `str`
void str(std::string const& str);
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push