Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

Made Colour copyable to remove warning

Commit
a469d9bc0f464db29b1c9d8c87ed2f3120e01324
Author
Phil Nash ·
Parents
a31f05fe8319

Files · Download .tar.gz

Changes

 include/internal/catch_console_colour.hpp      | 3 ++-
 include/internal/catch_console_colour_impl.hpp | 5 +++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/include/internal/catch_console_colour.hpp b/include/internal/catch_console_colour.hpp
index 2505f7bc..4caed07c 100644
--- a/include/internal/catch_console_colour.hpp
+++ b/include/internal/catch_console_colour.hpp
@@ -54,14 +54,15 @@ namespace Catch {
 
         // Use constructed object for RAII guard
         Colour( Code _colourCode );
+        Colour( Colour const& other );
         ~Colour();
 
         // Use static method for one-shot changes
         static void use( Code _colourCode );
 
     private:
-        Colour( Colour const& other );
         static Detail::IColourImpl* impl();
+        bool m_moved;
     };
 
     inline std::ostream& operator << ( std::ostream& os, Colour const& ) { return os; }
diff --git a/include/internal/catch_console_colour_impl.hpp b/include/internal/catch_console_colour_impl.hpp
index c159dc95..5f215062 100644
--- a/include/internal/catch_console_colour_impl.hpp
+++ b/include/internal/catch_console_colour_impl.hpp
@@ -149,8 +149,9 @@ namespace Catch {
         }
     }
 
-    Colour::Colour( Code _colourCode ){ use( _colourCode ); }
-    Colour::~Colour(){ use( None ); }
+    Colour::Colour( Code _colourCode ) : m_moved( false ) { use( _colourCode ); }
+    Colour::Colour( Colour const& _other ) : m_moved( false ) { const_cast<Colour&>( _other ).m_moved = true; }
+    Colour::~Colour(){ if( !m_moved ) use( None ); }
     void Colour::use( Code _colourCode ) {
         impl()->use( _colourCode );
     }