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

Removed SafeBool

Commit
cc8206f4c35cfcfdf1e6e61172800d122d69469e
Author
Phil Nash ·
Parents
e1bca7017da3

Files · Download .tar.gz

Changes

 include/internal/catch_common.h   | 11 -----------
 include/internal/catch_option.hpp |  4 ++--
 include/internal/catch_ptr.hpp    |  2 +-
 projects/SelfTest/TrickyTests.cpp |  4 ++--
 4 files changed, 5 insertions(+), 16 deletions(-)

diff --git a/include/internal/catch_common.h b/include/internal/catch_common.h
index c207d8e8..bcb6bd51 100644
--- a/include/internal/catch_common.h
+++ b/include/internal/catch_common.h
@@ -44,17 +44,6 @@ namespace Catch {
         virtual ~NonCopyable();
     };
 
-    class SafeBool {
-    public:
-        typedef void (SafeBool::*type)() const;
-
-        static type makeSafe( bool value ) {
-            return value ? &SafeBool::trueValue : 0;
-        }
-    private:
-        void trueValue() const {}
-    };
-
     template<typename ContainerT>
     inline void deleteAll( ContainerT& container ) {
         for( auto p : container )
diff --git a/include/internal/catch_option.hpp b/include/internal/catch_option.hpp
index c9c3c165..8b146da6 100644
--- a/include/internal/catch_option.hpp
+++ b/include/internal/catch_option.hpp
@@ -61,8 +61,8 @@ namespace Catch {
         bool none() const { return nullableValue == nullptr; }
 
         bool operator !() const { return nullableValue == nullptr; }
-        operator SafeBool::type() const {
-            return SafeBool::makeSafe( some() );
+        explicit operator bool() const {
+            return some();
         }
 
     private:
diff --git a/include/internal/catch_ptr.hpp b/include/internal/catch_ptr.hpp
index 5da73aa1..4197cf79 100644
--- a/include/internal/catch_ptr.hpp
+++ b/include/internal/catch_ptr.hpp
@@ -56,7 +56,7 @@ namespace Catch {
         T& operator*() const { return *m_p; }
         T* operator->() const { return m_p; }
         bool operator !() const { return m_p == nullptr; }
-        operator SafeBool::type() const { return SafeBool::makeSafe( m_p != nullptr ); }
+        explicit operator bool() const { return m_p != nullptr; }
 
     private:
         T* m_p;
diff --git a/projects/SelfTest/TrickyTests.cpp b/projects/SelfTest/TrickyTests.cpp
index 70c56965..05053fe3 100644
--- a/projects/SelfTest/TrickyTests.cpp
+++ b/projects/SelfTest/TrickyTests.cpp
@@ -293,8 +293,8 @@ struct Boolable
 {
     explicit Boolable( bool value ) : m_value( value ) {}
 
-    operator Catch::SafeBool::type() const {
-        return Catch::SafeBool::makeSafe( m_value );
+    explicit operator bool() const {
+        return m_value;
     }
 
     bool m_value;