[libsigc++2] trackable: Add move operations.



commit 482a6bb7a5c4e55084056fb2d5578f9ec61fa97c
Author: Murray Cumming <murrayc murrayc com>
Date:   Tue Sep 1 14:43:05 2015 +0200

    trackable: Add move operations.
    
    Also adding them to trackable_callback_list and makeing
    trackable_callback_list noncopyable, which I think is intended.

 sigc++/trackable.cc |   24 ++++++++++++++++++++++++
 sigc++/trackable.h  |   12 ++++++++++++
 2 files changed, 36 insertions(+), 0 deletions(-)
---
diff --git a/sigc++/trackable.cc b/sigc++/trackable.cc
index 2633d03..fd92029 100644
--- a/sigc++/trackable.cc
+++ b/sigc++/trackable.cc
@@ -38,6 +38,11 @@ trackable::trackable(const trackable& /*src*/)
 : callback_list_(nullptr)
 {}
 
+trackable::trackable(trackable&& src)
+: callback_list_(std::move(src.callback_list_))
+{
+}
+
 trackable& trackable::operator=(const trackable& src)
 {
   if(this != &src)
@@ -81,6 +86,25 @@ internal::trackable_callback_list* trackable::callback_list() const
 namespace internal
 {
 
+trackable_callback_list::trackable_callback_list(trackable_callback_list&& src) noexcept
+: callbacks_(std::move(src.callbacks_)),
+  clearing_(std::move(src.clearing_))
+{
+  src.callbacks_.clear();
+  src.clearing_ = false;
+}
+
+trackable_callback_list& trackable_callback_list::operator=(trackable_callback_list&& src) noexcept
+{
+  callbacks_ = std::move(src.callbacks_);
+  clearing_ = std::move(src.clearing_);
+
+  src.callbacks_.clear();
+  src.clearing_ = false;
+
+  return *this;
+}
+
 trackable_callback_list::~trackable_callback_list()
 {
   clearing_ = true;
diff --git a/sigc++/trackable.h b/sigc++/trackable.h
index 4563738..894d688 100644
--- a/sigc++/trackable.h
+++ b/sigc++/trackable.h
@@ -68,10 +68,18 @@ struct SIGC_API trackable_callback_list
   trackable_callback_list()
     : clearing_(false) {}
 
+  trackable_callback_list(const trackable_callback_list& src) = delete;
+  trackable_callback_list& operator=(const trackable_callback_list& src) = delete;
+
+  trackable_callback_list(trackable_callback_list&& src) noexcept;
+
+  trackable_callback_list& operator=(trackable_callback_list&& src) noexcept;
+
   /** This invokes all of the callback functions.
    */
   ~trackable_callback_list();
 
+
 private:
   typedef std::list<trackable_callback> callback_list;
   callback_list callbacks_;
@@ -107,8 +115,12 @@ struct SIGC_API trackable
 
   trackable(const trackable& src);
 
+  trackable(trackable&& src);
+
   trackable& operator=(const trackable& src);
 
+  trackable& operator=(trackable&& src);
+
   ~trackable();
 
   /*virtual ~trackable() {} */  /* we would need a virtual dtor for users


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