[glibmm] C++11: Use = delete instead of private copy operations.



commit 8fcab6221c17c90ef101215397309cf2c9d5b2f8
Author: Murray Cumming <murrayc murrayc com>
Date:   Sun Aug 23 18:40:26 2015 +0200

    C++11: Use = delete instead of private copy operations.
    
    There were still some left in the .hg/.ccg files.

 gio/src/dbusinterfacevtable.hg |   10 ++----
 gio/src/dbussubtreevtable.hg   |    9 ++---
 glib/src/convert.hg            |    7 ++--
 glib/src/fileutils.hg          |    7 ++--
 glib/src/keyfile.hg            |    8 ++---
 glib/src/markup.hg             |   14 ++++----
 glib/src/module.hg             |    8 ++---
 glib/src/regex.hg              |    6 ++--
 glib/src/thread.hg             |   69 +++++++++++++++++------------------
 glib/src/threads.hg            |   79 ++++++++++++++++++++--------------------
 10 files changed, 100 insertions(+), 117 deletions(-)
---
diff --git a/gio/src/dbusinterfacevtable.hg b/gio/src/dbusinterfacevtable.hg
index c17e82f..e69df93 100644
--- a/gio/src/dbusinterfacevtable.hg
+++ b/gio/src/dbusinterfacevtable.hg
@@ -126,6 +126,9 @@ public:
    const SlotInterfaceSetProperty& slot_set_property = SlotInterfaceSetProperty()
   );
 
+  InterfaceVTable(const InterfaceVTable& other) = delete;
+  InterfaceVTable& operator=(const InterfaceVTable& other) = delete;
+
   /// Destructor.
   virtual ~InterfaceVTable();
 
@@ -137,13 +140,6 @@ public:
   const GDBusInterfaceVTable* gobj() const
     { return reinterpret_cast<const GDBusInterfaceVTable*>(&gobject_); }
 
-
-private:
-  // Non-copyable.
-  InterfaceVTable(const InterfaceVTable& other);
-  InterfaceVTable& operator=(const InterfaceVTable& other);
-
-public:
 #ifndef DOXYGEN_SHOULD_SKIP_THIS
   // These are so the C callbacks and the
   // Gio::DBus::Connection::register_object() method can have access to the
diff --git a/gio/src/dbussubtreevtable.hg b/gio/src/dbussubtreevtable.hg
index ec519ed..a31452b 100644
--- a/gio/src/dbussubtreevtable.hg
+++ b/gio/src/dbussubtreevtable.hg
@@ -135,6 +135,9 @@ public:
    const SlotSubtreeDispatch& slot_dispatch = SlotSubtreeDispatch()
   );
 
+  SubtreeVTable(const SubtreeVTable& other) = delete;
+  SubtreeVTable& operator=(const SubtreeVTable& other) = delete;
+
   /// Destructor.
   virtual ~SubtreeVTable();
 
@@ -146,12 +149,6 @@ public:
   const GDBusSubtreeVTable* gobj() const
     { return reinterpret_cast<const GDBusSubtreeVTable*>(&gobject_); }
 
-
-private:
-  // Non-copyable.
-  SubtreeVTable(const SubtreeVTable& other);
-  SubtreeVTable& operator=(const SubtreeVTable& other);
-
 public:
 #ifndef DOXYGEN_SHOULD_SKIP_THIS
   // These are so the C callbacks and the
diff --git a/glib/src/convert.hg b/glib/src/convert.hg
index de5e12a..408ceb3 100644
--- a/glib/src/convert.hg
+++ b/glib/src/convert.hg
@@ -61,6 +61,9 @@ public:
   IConv(const std::string& to_codeset, const std::string& from_codeset);
   _IGNORE(g_iconv_open)
 
+  IConv(const IConv&) = delete;
+  IConv& operator=(const IConv&) = delete;
+
   explicit IConv(GIConv gobject);
 
   /** Close conversion descriptor.
@@ -99,10 +102,6 @@ public:
 
 private:
   GIConv gobject_;
-
-  // noncopyable
-  IConv(const IConv&);
-  IConv& operator=(const IConv&);
 };
 
 
diff --git a/glib/src/fileutils.hg b/glib/src/fileutils.hg
index f665f32..4320c42 100644
--- a/glib/src/fileutils.hg
+++ b/glib/src/fileutils.hg
@@ -271,6 +271,9 @@ public:
   explicit Dir(GDir* gobject);
 #endif
 
+  Dir(const Dir&) = delete;
+  Dir& operator=(const Dir&) = delete;
+
   /** Closes the directory and deallocates all related resources.
    */
   ~Dir();
@@ -306,10 +309,6 @@ public:
 
 private:
   GDir* gobject_;
-
-  // noncopyable
-  Dir(const Dir&);
-  Dir& operator=(const Dir&);
 };
 
 
diff --git a/glib/src/keyfile.hg b/glib/src/keyfile.hg
index c976a95..9a9db86 100644
--- a/glib/src/keyfile.hg
+++ b/glib/src/keyfile.hg
@@ -106,6 +106,9 @@ public:
    */
   KeyFile();
 
+  KeyFile(const KeyFile&) = delete;
+  KeyFile& operator=(const KeyFile&) = delete;
+
   /** Destructor
    */
   ~KeyFile();
@@ -425,11 +428,6 @@ public:
 protected:
   GKeyFile* gobject_;
   bool owns_gobject_;
-
-private:
-  // noncopyable
-  KeyFile(const KeyFile&);
-  KeyFile& operator=(const KeyFile&);
 };
 
 } // namespace Glib
diff --git a/glib/src/markup.hg b/glib/src/markup.hg
index 6ad7f51..005eab1 100644
--- a/glib/src/markup.hg
+++ b/glib/src/markup.hg
@@ -173,6 +173,9 @@ protected:
    */
   Parser();
 
+  Parser(const Parser&) = delete;
+  Parser& operator=(const Parser&) = delete;
+
   /** Called for open tags <tt>\<foo bar="baz"\></tt>.
    * This virtual method is invoked when the opening tag of an element is seen.
    * @param context The Markup::ParseContext object the parsed data belongs to.
@@ -235,9 +238,6 @@ protected:
   virtual void on_error(ParseContext& context, const MarkupError& error);
 
 private:
-  // noncopyable
-  Parser(const Parser&);
-  Parser& operator=(const Parser&);
 
 #ifndef DOXYGEN_SHOULD_SKIP_THIS
   friend class Glib::Markup::ParserCallbacks;
@@ -259,6 +259,10 @@ public:
    * @param flags Bitwise combination of Markup::ParseFlags.
    */
   explicit ParseContext(Parser& parser, ParseFlags flags = ParseFlags(0));
+
+  ParseContext(const ParseContext&) = delete;
+  ParseContext& operator=(const ParseContext&) = delete;
+
   virtual ~ParseContext();
 
   /** Feed some data to the ParseContext.
@@ -326,10 +330,6 @@ private:
   Markup::Parser*       parser_;
   GMarkupParseContext*  gobject_;
 
-  // noncopyable
-  ParseContext(const ParseContext&);
-  ParseContext& operator=(const ParseContext&);
-
   static void destroy_notify_callback(void* data);
 };
 
diff --git a/glib/src/module.hg b/glib/src/module.hg
index f1caf77..ca98689 100644
--- a/glib/src/module.hg
+++ b/glib/src/module.hg
@@ -71,6 +71,9 @@ public:
    */
   explicit Module(const std::string& file_name, ModuleFlags flags = ModuleFlags(0));
 
+  Module(const Module&) = delete;
+  Module& operator=(const Module&) = delete;
+
   /** Close a module. The module will be removed from memory, unless
    * <tt>make_resident</tt> has been called.
    */
@@ -137,11 +140,6 @@ public:
 
 protected:
   GModule* gobject_;
-
-private:
-  // noncopyable
-  Module(const Module&);
-  Module& operator=(const Module&);
 };
 
 } // namespace Glib
diff --git a/glib/src/regex.hg b/glib/src/regex.hg
index 0ad6f09..6e0d9d3 100644
--- a/glib/src/regex.hg
+++ b/glib/src/regex.hg
@@ -227,6 +227,9 @@ public:
    */
   explicit MatchInfo(GMatchInfo* castitem, bool take_the_ownership = true); //TODO: Rename to take_ownership 
when we can rename the member variable.
 
+  MatchInfo(const MatchInfo& other) = delete;
+  MatchInfo& operator=(const MatchInfo& other) = delete;
+
   /// Destructor.
   virtual ~MatchInfo();
 
@@ -239,9 +242,6 @@ public:
     { return reinterpret_cast<GMatchInfo*>(gobject_); }
 
 private:
-// noncopyable
-  MatchInfo(const MatchInfo& other);
-  MatchInfo& operator=(const MatchInfo& other);
 
   friend class Regex;
 
diff --git a/glib/src/thread.hg b/glib/src/thread.hg
index b5efa43..24df5de 100644
--- a/glib/src/thread.hg
+++ b/glib/src/thread.hg
@@ -160,6 +160,10 @@ _WRAP_GERROR(ThreadError, GThreadError, G_THREAD_ERROR, NO_GTYPE)
 class Thread
 {
 public:
+
+  Thread(const Thread&) = delete;
+  Thread& operator=(const Thread&) = delete;
+
   class Exit;
 
   //See http://bugzilla.gnome.org/show_bug.cgi?id=512348 about the sigc::trackable issue.
@@ -287,10 +291,6 @@ private:
   // Glib::Thread can neither be constructed nor deleted.
   Thread();
   void operator delete(void*, std::size_t);
-
-  // noncopyable
-  Thread(const Thread&);
-  Thread& operator=(const Thread&);
 };
 
 /** %Exception class used to exit from a thread.
@@ -371,6 +371,10 @@ public:
   class Lock;
 
   Mutex();
+
+  Mutex(const Mutex&) = delete;
+  Mutex& operator=(const Mutex&) = delete;
+
   ~Mutex();
 
   /** Locks the mutex.
@@ -399,10 +403,6 @@ public:
 
 private:
   GMutex* gobject_;
-
-  // noncopyable
-  Mutex(const Mutex&);
-  Mutex& operator=(const Mutex&);
 };
 
 /** Utility class for exception-safe mutex locking.
@@ -437,9 +437,7 @@ private:
   Mutex&  mutex_;
   bool    locked_;
 
-  // noncopyable
-  Lock(const Mutex::Lock&);
-  Mutex::Lock& operator=(const Mutex::Lock&);
+
 };
 
 
@@ -502,6 +500,10 @@ public:
   explicit inline Lock(RecMutex& mutex);
   inline Lock(RecMutex& mutex, NotLock);
   inline Lock(RecMutex& mutex, TryLock);
+
+  Lock(const RecMutex::Lock&) = delete;
+  RecMutex::Lock& operator=(const RecMutex::Lock&) = delete;
+
   inline ~Lock();
 
   inline void acquire();
@@ -512,10 +514,6 @@ public:
 private:
   RecMutex& mutex_;
   bool      locked_;
-
-  // noncopyable
-  Lock(const RecMutex::Lock&);
-  RecMutex::Lock& operator=(const RecMutex::Lock&);
 };
 
 
@@ -562,12 +560,11 @@ public:
   class WriterLock;
 
   RWLock();
-  ~RWLock();
 
-private:
-  // noncopyable
-  RWLock(const RWLock&);
-  RWLock& operator=(const RWLock&);
+  RWLock(const RWLock&) = delete;
+  RWLock& operator=(const RWLock&) = delete;
+
+  ~RWLock();
 };
 
 /** Utility class for exception-safe locking of read/write locks.
@@ -580,6 +577,10 @@ public:
   explicit inline ReaderLock(RWLock& rwlock);
   inline ReaderLock(RWLock& rwlock, NotLock);
   inline ReaderLock(RWLock& rwlock, TryLock);
+
+  ReaderLock(const RWLock::ReaderLock&) = delete;
+  RWLock::ReaderLock& operator=(const RWLock::ReaderLock&) = delete;
+
   inline ~ReaderLock();
 
   inline void acquire();
@@ -590,10 +591,6 @@ public:
 private:
   RWLock& rwlock_;
   bool    locked_;
-
-  // noncopyable
-  ReaderLock(const RWLock::ReaderLock&);
-  RWLock::ReaderLock& operator=(const RWLock::ReaderLock&);
 };
 
 /** Utility class for exception-safe locking of read/write locks.
@@ -606,6 +603,10 @@ public:
   explicit inline WriterLock(RWLock& rwlock);
   inline WriterLock(RWLock& rwlock, NotLock);
   inline WriterLock(RWLock& rwlock, TryLock);
+
+  WriterLock(const RWLock::WriterLock&) = delete;
+  RWLock::WriterLock& operator=(const RWLock::WriterLock&) = delete;
+
   inline ~WriterLock();
 
   inline void acquire();
@@ -616,10 +617,6 @@ public:
 private:
   RWLock& rwlock_;
   bool    locked_;
-
-  // noncopyable
-  WriterLock(const RWLock::WriterLock&);
-  RWLock::WriterLock& operator=(const RWLock::WriterLock&);
 };
 
 /** An opaque data structure to represent a condition.
@@ -660,6 +657,10 @@ class Cond
 {
 public:
   Cond();
+
+  Cond(const Cond&) = delete;
+  Cond& operator=(const Cond&) = delete;
+
   ~Cond();
 
   /** If threads are waiting for this @a Cond, exactly one of them is woken up.
@@ -708,10 +709,6 @@ public:
 
 private:
   GCond* gobject_;
-
-  // noncopyable
-  Cond(const Cond&);
-  Cond& operator=(const Cond&);
 };
 
 
@@ -745,6 +742,10 @@ template <class T>
 class Private
 {
 public:
+
+  Private(const Private<T>&) = delete;
+  Private<T>& operator=(const Private<T>&) = delete;
+
   typedef void (*DestructorFunc) (void*);
 
   static void delete_ptr(void* data);
@@ -757,10 +758,6 @@ public:
 
 private:
   GPrivate* gobject_;
-
-  // noncopyable
-  Private(const Private<T>&);
-  Private<T>& operator=(const Private<T>&);
 };
 
 /** @} group Threads */
diff --git a/glib/src/threads.hg b/glib/src/threads.hg
index 412d5fb..691af05 100644
--- a/glib/src/threads.hg
+++ b/glib/src/threads.hg
@@ -75,6 +75,10 @@ _WRAP_GERROR(ThreadError, GThreadError, G_THREAD_ERROR, NO_GTYPE)
 class Thread
 {
 public:
+
+  Thread(const Thread&) = delete;
+  Thread& operator=(const Thread&) = delete;
+
   class Exit;
 
   //See http://bugzilla.gnome.org/show_bug.cgi?id=512348 about the sigc::trackable issue.
@@ -154,10 +158,6 @@ private:
   // Glib::Thread can neither be constructed nor deleted.
   Thread();
   void operator delete(void*, std::size_t);
-
-  // noncopyable
-  Thread(const Thread&);
-  Thread& operator=(const Thread&);
 };
 
 /** %Exception class used to exit from a thread.
@@ -195,6 +195,10 @@ public:
   class Lock;
 
   Mutex();
+
+  Mutex(const Mutex&) = delete;
+  Mutex& operator=(const Mutex&) = delete;
+
   ~Mutex();
 
   /** Locks the mutex.
@@ -223,10 +227,6 @@ public:
 
 private:
   GMutex gobject_;
-
-  // noncopyable
-  Mutex(const Mutex&);
-  Mutex& operator=(const Mutex&);
 };
 
 /** Utility class for exception-safe mutex locking.
@@ -248,6 +248,10 @@ public:
   explicit inline Lock(Mutex& mutex);
   inline Lock(Mutex& mutex, NotLock);
   inline Lock(Mutex& mutex, TryLock);
+
+  Lock(const Mutex::Lock&) = delete;
+  Mutex::Lock& operator=(const Mutex::Lock&) = delete;
+
   inline ~Lock();
 
   inline void acquire();
@@ -258,10 +262,6 @@ public:
 private:
   Mutex&  mutex_;
   bool    locked_;
-
-  // noncopyable
-  Lock(const Mutex::Lock&);
-  Mutex::Lock& operator=(const Mutex::Lock&);
 };
 
 /** A C++ wrapper for the C object.
@@ -288,6 +288,10 @@ public:
   class Lock;
 
   RecMutex();
+
+  RecMutex(const RecMutex&) = delete;
+  RecMutex& operator=(const RecMutex&) = delete;
+
   ~RecMutex();
 
   void lock();
@@ -297,10 +301,6 @@ public:
   GRecMutex* gobj() { return &gobject_; }
 
 private:
-  // noncopyable
-  RecMutex(const RecMutex&);
-  RecMutex& operator=(const RecMutex&);
-
   GRecMutex gobject_;
 };
 
@@ -312,6 +312,10 @@ public:
   explicit inline Lock(RecMutex& mutex);
   inline Lock(RecMutex& mutex, NotLock);
   inline Lock(RecMutex& mutex, TryLock);
+
+  Lock(const RecMutex::Lock&) = delete;
+  RecMutex::Lock& operator=(const RecMutex::Lock&) = delete;
+
   inline ~Lock();
 
   inline void acquire();
@@ -322,10 +326,6 @@ public:
 private:
   RecMutex& mutex_;
   bool      locked_;
-
-  // noncopyable
-  Lock(const RecMutex::Lock&);
-  RecMutex::Lock& operator=(const RecMutex::Lock&);
 };
 
 /** A C++ wrapper for the C object.
@@ -358,6 +358,10 @@ public:
   class WriterLock;
 
   RWLock();
+
+  RWLock(const RWLock&) = delete;
+  RWLock& operator=(const RWLock&) = delete;
+
   ~RWLock();
 
   void reader_lock();
@@ -371,10 +375,6 @@ public:
   GRWLock* gobj() { return &gobject_; }
 
 private:
-  // noncopyable
-  RWLock(const RWLock&);
-  RWLock& operator=(const RWLock&);
-
   GRWLock gobject_;
 };
 
@@ -386,6 +386,10 @@ public:
   explicit inline ReaderLock(RWLock& rwlock);
   inline ReaderLock(RWLock& rwlock, NotLock);
   inline ReaderLock(RWLock& rwlock, TryLock);
+
+  ReaderLock(const RWLock::ReaderLock&) = delete;
+  RWLock::ReaderLock& operator=(const RWLock::ReaderLock&) = delete;
+
   inline ~ReaderLock();
 
   inline void acquire();
@@ -396,10 +400,6 @@ public:
 private:
   RWLock& rwlock_;
   bool    locked_;
-
-  // noncopyable
-  ReaderLock(const RWLock::ReaderLock&);
-  RWLock::ReaderLock& operator=(const RWLock::ReaderLock&);
 };
 
 /** Utility class for exception-safe locking of read/write locks.
@@ -410,6 +410,10 @@ public:
   explicit inline WriterLock(RWLock& rwlock);
   inline WriterLock(RWLock& rwlock, NotLock);
   inline WriterLock(RWLock& rwlock, TryLock);
+
+  WriterLock(const RWLock::WriterLock&) = delete;
+  RWLock::WriterLock& operator=(const RWLock::WriterLock&) = delete;
+
   inline ~WriterLock();
 
   inline void acquire();
@@ -420,10 +424,6 @@ public:
 private:
   RWLock& rwlock_;
   bool    locked_;
-
-  // noncopyable
-  WriterLock(const RWLock::WriterLock&);
-  RWLock::WriterLock& operator=(const RWLock::WriterLock&);
 };
 
 /** An opaque data structure to represent a condition.
@@ -462,6 +462,10 @@ class Cond
 {
 public:
   Cond();
+
+  Cond(const Cond&) = delete;
+  Cond& operator=(const Cond&) = delete;
+
   ~Cond();
 
   /** If threads are waiting for this @a Cond, exactly one of them is woken up.
@@ -538,10 +542,6 @@ public:
 
 private:
   GCond gobject_;
-
-  // noncopyable
-  Cond(const Cond&);
-  Cond& operator=(const Cond&);
 };
 
 /** Thread-local data pointer.
@@ -554,6 +554,9 @@ template <class T>
 class Private
 {
 public:
+  Private(const Private<T>&) = delete;
+  Private<T>& operator=(const Private<T>&) = delete;
+
   typedef void (*DestructorFunc) (void*);
 
   /** Deletes static_cast<T*>(data)
@@ -591,10 +594,6 @@ public:
 
 private:
   GPrivate gobject_;
-
-  // noncopyable
-  Private(const Private<T>&);
-  Private<T>& operator=(const Private<T>&);
 };
 
 /** @} group Threads */


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