diff options
| author | Martin Hořeňovský | 2022-04-12 20:59:01 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2022-04-13 14:59:39 +0200 |
| commit | 4f09f1120ba0a28f218a00821a8347a443042ecb (patch) | |
| tree | af5dc04a3e0c91476e0b03e60d914d5bf2b11693 /src/catch2/internal/catch_stream.cpp | |
| parent | 9934b7de13ef303e0d7b1bccf519422be73c6a03 (diff) | |
| download | catch3-4f09f1120ba0a28f218a00821a8347a443042ecb.tar.gz | |
Make IStream::stream non-const
This way it makes much more sense from logically-const point
of view, and also means that concrete implementations don't
have to always have a `mutable` keyword on the stream member.
Diffstat (limited to 'src/catch2/internal/catch_stream.cpp')
| -rw-r--r-- | src/catch2/internal/catch_stream.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/catch2/internal/catch_stream.cpp b/src/catch2/internal/catch_stream.cpp index dfa322c7..089a7583 100644 --- a/src/catch2/internal/catch_stream.cpp +++ b/src/catch2/internal/catch_stream.cpp @@ -74,7 +74,7 @@ namespace Detail { /////////////////////////////////////////////////////////////////////////// class FileStream : public IStream { - mutable std::ofstream m_ofs; + std::ofstream m_ofs; public: FileStream( std::string const& filename ) { m_ofs.open( filename.c_str() ); @@ -82,7 +82,7 @@ namespace Detail { } ~FileStream() override = default; public: // IStream - std::ostream& stream() const override { + std::ostream& stream() override { return m_ofs; } }; @@ -90,7 +90,7 @@ namespace Detail { /////////////////////////////////////////////////////////////////////////// class CoutStream : public IStream { - mutable std::ostream m_os; + std::ostream m_os; public: // Store the streambuf from cout up-front because // cout may get redirected when running tests @@ -98,12 +98,12 @@ namespace Detail { ~CoutStream() override = default; public: // IStream - std::ostream& stream() const override { return m_os; } + std::ostream& stream() override { return m_os; } bool isConsole() const override { return true; } }; class CerrStream : public IStream { - mutable std::ostream m_os; + std::ostream m_os; public: // Store the streambuf from cerr up-front because @@ -112,7 +112,7 @@ namespace Detail { ~CerrStream() override = default; public: // IStream - std::ostream& stream() const override { return m_os; } + std::ostream& stream() override { return m_os; } bool isConsole() const override { return true; } }; @@ -120,7 +120,7 @@ namespace Detail { class DebugOutStream : public IStream { Detail::unique_ptr<StreamBufImpl<OutputDebugWriter>> m_streamBuf; - mutable std::ostream m_os; + std::ostream m_os; public: DebugOutStream() : m_streamBuf( Detail::make_unique<StreamBufImpl<OutputDebugWriter>>() ), @@ -130,7 +130,7 @@ namespace Detail { ~DebugOutStream() override = default; public: // IStream - std::ostream& stream() const override { return m_os; } + std::ostream& stream() override { return m_os; } }; } // unnamed namespace @@ -138,7 +138,7 @@ namespace Detail { /////////////////////////////////////////////////////////////////////////// - auto makeStream( std::string const& filename ) -> Detail::unique_ptr<IStream const> { + auto makeStream( std::string const& filename ) -> Detail::unique_ptr<IStream> { if ( filename.empty() || filename == "-" ) { return Detail::make_unique<Detail::CoutStream>(); } |