mirror of
https://github.com/catchorg/Catch2.git
synced 2025-09-25 22:15:39 +02:00
Compare commits
2 Commits
devel-cont
...
devel
Author | SHA1 | Date | |
---|---|---|---|
![]() |
3bcd0a4e74 | ||
![]() |
f7e7fa0983 |
@@ -78,5 +78,5 @@ WarningsAsErrors: >-
|
|||||||
readability-duplicate-include,
|
readability-duplicate-include,
|
||||||
HeaderFilterRegex: '.*\.(c|cxx|cpp)$'
|
HeaderFilterRegex: '.*\.(c|cxx|cpp)$'
|
||||||
FormatStyle: none
|
FormatStyle: none
|
||||||
CheckOptions: {}
|
CheckOptions: []
|
||||||
...
|
...
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <tuple>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
@@ -23,16 +24,16 @@ namespace Catch {
|
|||||||
std::ostringstream m_referenceStream; // Used for copy state/ flags from
|
std::ostringstream m_referenceStream; // Used for copy state/ flags from
|
||||||
Detail::Mutex m_mutex;
|
Detail::Mutex m_mutex;
|
||||||
|
|
||||||
auto add() -> std::size_t {
|
auto add() -> std::pair<std::size_t, std::ostringstream*> {
|
||||||
Detail::LockGuard _( m_mutex );
|
Detail::LockGuard _( m_mutex );
|
||||||
if( m_unused.empty() ) {
|
if( m_unused.empty() ) {
|
||||||
m_streams.push_back( Detail::make_unique<std::ostringstream>() );
|
m_streams.push_back( Detail::make_unique<std::ostringstream>() );
|
||||||
return m_streams.size()-1;
|
return { m_streams.size()-1, m_streams.back().get() };
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
auto index = m_unused.back();
|
auto index = m_unused.back();
|
||||||
m_unused.pop_back();
|
m_unused.pop_back();
|
||||||
return index;
|
return { index, m_streams[index].get() };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,10 +47,10 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ReusableStringStream::ReusableStringStream()
|
ReusableStringStream::ReusableStringStream() {
|
||||||
: m_index( Singleton<StringStreams>::getMutable().add() ),
|
std::tie( m_index, m_oss ) =
|
||||||
m_oss( Singleton<StringStreams>::getMutable().m_streams[m_index].get() )
|
Singleton<StringStreams>::getMutable().add();
|
||||||
{}
|
}
|
||||||
|
|
||||||
ReusableStringStream::~ReusableStringStream() {
|
ReusableStringStream::~ReusableStringStream() {
|
||||||
static_cast<std::ostringstream*>( m_oss )->str("");
|
static_cast<std::ostringstream*>( m_oss )->str("");
|
||||||
|
Reference in New Issue
Block a user