[libsigc++2] C++11: Use of nullptr instead of 0.



commit f621f11dfe6407eabd55f4db0db18fe9a53c0f5f
Author: Murray Cumming <murrayc murrayc com>
Date:   Sat Jul 18 10:46:20 2015 +0200

    C++11: Use of nullptr instead of 0.

 sigc++/connection.cc                |    4 ++--
 sigc++/functors/macros/mem_fun.h.m4 |    2 +-
 sigc++/functors/macros/slot.h.m4    |    8 ++++----
 sigc++/functors/slot_base.cc        |   20 ++++++++++----------
 sigc++/functors/slot_base.h         |    2 +-
 sigc++/signal_base.cc               |    2 +-
 sigc++/trackable.cc                 |   10 +++++-----
 sigc++/type_traits.h                |    2 +-
 tests/test_bind_refptr.cc           |    4 ++--
 tests/test_track_obj.cc             |    6 +++---
 tests/testutilities.cc              |    4 ++--
 11 files changed, 32 insertions(+), 32 deletions(-)
---
diff --git a/sigc++/connection.cc b/sigc++/connection.cc
index ff785e5..487e459 100644
--- a/sigc++/connection.cc
+++ b/sigc++/connection.cc
@@ -24,7 +24,7 @@ using namespace std;
 namespace sigc {
 
 connection::connection()
-: slot_(0)
+: slot_(nullptr)
 {}
 
 connection::connection(const connection& c)
@@ -104,7 +104,7 @@ void connection::set_slot(slot_base* sl)
 void* connection::notify(void* data)
 {
   connection* self = reinterpret_cast<connection*>(data);
-  self->slot_ = 0;
+  self->slot_ = nullptr;
   return 0;
 }
 
diff --git a/sigc++/functors/macros/mem_fun.h.m4 b/sigc++/functors/macros/mem_fun.h.m4
index 2763796..6aaf8e3 100644
--- a/sigc++/functors/macros/mem_fun.h.m4
+++ b/sigc++/functors/macros/mem_fun.h.m4
@@ -38,7 +38,7 @@ public:
   typedef T_return result_type;
 
   /// Constructs an invalid functor.
-  [$2]mem_functor$1() : func_ptr_(0) {}
+  [$2]mem_functor$1() : func_ptr_(nullptr) {}
 
   /** Constructs a [$2]mem_functor$1 object that wraps the passed method.
    * @param _A_func Pointer to method will be invoked from operator()().
diff --git a/sigc++/functors/macros/slot.h.m4 b/sigc++/functors/macros/slot.h.m4
index eea7bf2..dac433c 100644
--- a/sigc++/functors/macros/slot.h.m4
+++ b/sigc++/functors/macros/slot.h.m4
@@ -247,8 +247,8 @@ struct typed_slot_rep : public slot_rep
 
   inline ~typed_slot_rep()
     {
-      call_ = 0;
-      destroy_ = 0;
+      call_ = nullptr;
+      destroy_ = nullptr;
       sigc::visit_each_type<trackable*>(slot_do_unbind(this), functor_);
     }
 
@@ -258,8 +258,8 @@ struct typed_slot_rep : public slot_rep
   static void* destroy(void* data)
     {
       self* self_ = static_cast<self*>(reinterpret_cast<slot_rep*>(data));
-      self_->call_ = 0;
-      self_->destroy_ = 0;
+      self_->call_ = nullptr;
+      self_->destroy_ = nullptr;
       sigc::visit_each_type<trackable*>(slot_do_unbind(self_), self_->functor_);
       self_->functor_.~adaptor_type();
       /* don't call disconnect() here: destroy() is either called
diff --git a/sigc++/functors/slot_base.cc b/sigc++/functors/slot_base.cc
index 3fe3b67..1ddaed7 100644
--- a/sigc++/functors/slot_base.cc
+++ b/sigc++/functors/slot_base.cc
@@ -63,15 +63,15 @@ void slot_rep::disconnect()
 {
   if (parent_)
   {
-    call_ = 0;          // Invalidate the slot.
+    call_ = nullptr;          // Invalidate the slot.
                         // _Must_ be done here because parent_ might defer the actual
                         // destruction of the slot_rep and try to invoke it before that point.
     void* data_ = parent_;
-    parent_ = 0;        // Just a precaution.
+    parent_ = nullptr;        // Just a precaution.
     (cleanup_)(data_);  // Notify the parent (might lead to destruction of this!).
   }
   else
-    call_ = 0;
+    call_ = nullptr;
 }
 
 //static
@@ -79,7 +79,7 @@ void* slot_rep::notify(void* data)
 {
   slot_rep* self_ = reinterpret_cast<slot_rep*>(data);
 
-  self_->call_ = 0; // Invalidate the slot.
+  self_->call_ = nullptr; // Invalidate the slot.
   
   // Make sure we are notified if disconnect() deletes self_, which is trackable.
   destroy_notify_struct notifier;
@@ -98,7 +98,7 @@ void* slot_rep::notify(void* data)
 } // namespace internal
   
 slot_base::slot_base()
-: rep_(0),
+: rep_(nullptr),
   blocked_(false)
 {}
 
@@ -108,7 +108,7 @@ slot_base::slot_base(rep_type* rep)
 {}
 
 slot_base::slot_base(const slot_base& src)
-: rep_(0),
+: rep_(nullptr),
   blocked_(src.blocked_)
 {
   if (src.rep_)
@@ -133,7 +133,7 @@ slot_base::~slot_base()
 
 slot_base::operator bool() const
 {
-  return rep_ != 0;
+  return rep_ != nullptr;
 }
 
 slot_base& slot_base::operator=(const slot_base& src)
@@ -158,7 +158,7 @@ slot_base& slot_base::operator=(const slot_base& src)
       {
         rep_->remove_destroy_notify_callback(&notifier);
         delete rep_; // Detach the stored functor from the other referred trackables and destroy it.
-        rep_ = 0;
+        rep_ = nullptr;
       }
     }
     return *this;
@@ -219,9 +219,9 @@ void slot_base::disconnect()
   if (rep_ && !rep_->call_)
     {
       delete rep_;        // This is not strictly necessary here. I'm convinced that it is
-      rep_ = 0;           // safe to wait for the destructor to delete the slot_rep. Martin.
+      rep_ = nullptr;           // safe to wait for the destructor to delete the slot_rep. Martin.
     }
-  return (rep_ == 0);
+  return (rep_ == nullptr);
 }*/
 
 } //namespace sigc
diff --git a/sigc++/functors/slot_base.h b/sigc++/functors/slot_base.h
index 29c64c1..23763f6 100644
--- a/sigc++/functors/slot_base.h
+++ b/sigc++/functors/slot_base.h
@@ -81,7 +81,7 @@ struct SIGC_API slot_rep : public trackable
   void* parent_;
 
   inline slot_rep(hook call__, hook destroy__, hook dup__)
-    : call_(call__), destroy_(destroy__), dup_(dup__), cleanup_(0), parent_(0) {}
+    : call_(call__), destroy_(destroy__), dup_(dup__), cleanup_(nullptr), parent_(nullptr) {}
 
   inline ~slot_rep()
     { destroy(); }
diff --git a/sigc++/signal_base.cc b/sigc++/signal_base.cc
index 7033c66..167bf72 100644
--- a/sigc++/signal_base.cc
+++ b/sigc++/signal_base.cc
@@ -157,7 +157,7 @@ void* signal_impl::notify(void* d)
 } /* namespace internal */
 
 signal_base::signal_base()
-: impl_(0)
+: impl_(nullptr)
 {}
 
 signal_base::signal_base(const signal_base& src)
diff --git a/sigc++/trackable.cc b/sigc++/trackable.cc
index f7e4cb7..1e8fabc 100644
--- a/sigc++/trackable.cc
+++ b/sigc++/trackable.cc
@@ -29,13 +29,13 @@ namespace sigc
 {
 
 trackable::trackable()
-: callback_list_(0)
+: callback_list_(nullptr)
 {}
 
 /* Don't copy the notification list.
    The objects watching src don't need to be notified when the new object dies. */
 trackable::trackable(const trackable& /*src*/)
-: callback_list_(0)
+: callback_list_(nullptr)
 {}
 
 trackable& trackable::operator=(const trackable& src)
@@ -66,7 +66,7 @@ void trackable::notify_callbacks()
   if (callback_list_)
     delete callback_list_; //This invokes all of the callbacks.
 
-  callback_list_ = 0;
+  callback_list_ = nullptr;
 }
 
 internal::trackable_callback_list* trackable::callback_list() const
@@ -114,13 +114,13 @@ void trackable_callback_list::clear()
 void trackable_callback_list::remove_callback(void* data)
 {
   for (callback_list::iterator i = callbacks_.begin(); i != callbacks_.end(); ++i)
-    if ((*i).data_ == data && (*i).func_ != 0)
+    if ((*i).data_ == data && (*i).func_ != nullptr)
     {
       //Don't remove a list element while the list is being cleared.
       //It could invalidate the iterator in ~trackable_callback_list() or clear().
       //But it may be necessary to invalidate the callback. See bug 589202.
       if (clearing_)
-        (*i).func_ = 0;
+        (*i).func_ = nullptr;
       else
         callbacks_.erase(i);
       return;
diff --git a/sigc++/type_traits.h b/sigc++/type_traits.h
index e76e89d..811be19 100644
--- a/sigc++/type_traits.h
+++ b/sigc++/type_traits.h
@@ -121,7 +121,7 @@ private:
 
 public:
   static const bool value =
-    sizeof(internal_class::is_base_class_(reinterpret_cast<typename type_trait<T_derived>::pointer>(0))) ==
+    sizeof(internal_class::is_base_class_(reinterpret_cast<typename 
type_trait<T_derived>::pointer>(nullptr))) ==
     sizeof(char);
 
 #else //SIGC_SELF_REFERENCE_IN_MEMBER_INITIALIZATION
diff --git a/tests/test_bind_refptr.cc b/tests/test_bind_refptr.cc
index edbf766..399b567 100644
--- a/tests/test_bind_refptr.cc
+++ b/tests/test_bind_refptr.cc
@@ -212,7 +212,7 @@ T_CppObject* RefPtr<T_CppObject>::operator->() const
 template <class T_CppObject> inline
 RefPtr<T_CppObject>::RefPtr()
 :
-  pCppObject_ (0)
+  pCppObject_ (nullptr)
 {}
 
 template <class T_CppObject> inline
@@ -319,7 +319,7 @@ bool RefPtr<T_CppObject>::operator!=(const RefPtr<T_CppObject>& src) const
 template <class T_CppObject> inline
 RefPtr<T_CppObject>::operator bool() const
 {
-  return (pCppObject_ != 0);
+  return (pCppObject_ != nullptr);
 }
 
 #ifndef GLIBMM_DISABLE_DEPRECATED
diff --git a/tests/test_track_obj.cc b/tests/test_track_obj.cc
index e3345d3..8ef6596 100644
--- a/tests/test_track_obj.cc
+++ b/tests/test_track_obj.cc
@@ -148,13 +148,13 @@ int main(int argc, char* argv[])
   util->check_result(result_stream, "zero, Book title: A Book");
 
   delete pbook4; // auto-disconnect *psl2
-  pbook4 = 0;
+  pbook4 = nullptr;
   result_stream << (*psl2)(0, "Book title: ");
   util->check_result(result_stream, "");
   delete psl2;
-  psl2 = 0;
+  psl2 = nullptr;
   delete pbar4;
-  pbar4 = 0;
+  pbar4 = nullptr;
 
 
 //C++11 lambda expressions:
diff --git a/tests/testutilities.cc b/tests/testutilities.cc
index b5d3d4c..4d8de22 100644
--- a/tests/testutilities.cc
+++ b/tests/testutilities.cc
@@ -21,7 +21,7 @@
 #include <iostream>
 #include <cstring>
 
-TestUtilities* TestUtilities::instance_ = 0;
+TestUtilities* TestUtilities::instance_ = nullptr;
 
 TestUtilities::TestUtilities()
 : verbose_(false), result_ok_(true), test_number_(0)
@@ -87,6 +87,6 @@ bool TestUtilities::get_result_and_delete_instance()
 {
   const bool result = instance_ ? instance_->result_ok_ : true;
   delete instance_;
-  instance_ = 0;
+  instance_ = nullptr;
   return result;
 }


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