[libsigc++2] C++11: Make all operator bool() explicit.



commit 37d1706b010ede18994fc4e6821829403a437d82
Author: Murray Cumming <murrayc murrayc com>
Date:   Thu Mar 3 13:08:54 2016 +0100

    C++11: Make all operator bool() explicit.

 sigc++/connection.h         |    4 ++--
 sigc++/functors/slot_base.h |    2 +-
 tests/test_bind_refptr.cc   |    6 +-----
 3 files changed, 4 insertions(+), 8 deletions(-)
---
diff --git a/sigc++/connection.h b/sigc++/connection.h
index 2405876..81ad07a 100644
--- a/sigc++/connection.h
+++ b/sigc++/connection.h
@@ -104,11 +104,11 @@ struct SIGC_API connection
   /// Disconnects the referred slot.
   void disconnect();
 
-  //TODO: When we can break API and ABI, make operator bool() explicit and const
+  //TODO: When we can break API and ABI, make operator bool() const
   /** Returns whether the connection is still active.
    * @return @p true if the connection is still active.
    */
-  operator bool() noexcept;
+  explicit operator bool() noexcept;
 
   /** Callback that is executed when the referred slot is destroyed.
    * @param data The connection object notified (@p this).
diff --git a/sigc++/functors/slot_base.h b/sigc++/functors/slot_base.h
index 5dd4d22..49f18da 100644
--- a/sigc++/functors/slot_base.h
+++ b/sigc++/functors/slot_base.h
@@ -282,7 +282,7 @@ public:
    *  do_something()
    * @endcode
    */
-  operator bool() const noexcept;
+  explicit operator bool() const noexcept;
 
   /** Sets the parent of this slot.
    * This function is used by signals to register a notification callback.
diff --git a/tests/test_bind_refptr.cc b/tests/test_bind_refptr.cc
index a432cf1..f8fe446 100644
--- a/tests/test_bind_refptr.cc
+++ b/tests/test_bind_refptr.cc
@@ -127,7 +127,7 @@ public:
    *     do_something();
    * @endcode
    */
-  inline operator bool() const;
+  inline explicit operator bool() const;
 
 #ifndef GLIBMM_DISABLE_DEPRECATED
   /// @deprecated Use reset() instead because this leads to confusion with clear() methods on the underlying 
class. For instance, people use .clear() when they mean ->clear().
@@ -169,10 +169,6 @@ public:
   template <class T_CastFrom>
   static inline RefPtr<T_CppObject> cast_const(const RefPtr<T_CastFrom>& src);
 
-  //TODO: Maybe remove these if we replace operator bool() with operator const void* after
-  //an API/ABI break, as suggested by Daniel Elstner? murrayc.
-  //See bug https://bugzilla.gnome.org/show_bug.cgi?id=626858
-
   /** Compare based on the underlying instance address.
    *
    * This is needed in code that requires an ordering on


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]