]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Rely on copy elision in scope-exit.h
authorTom Tromey <tom@tromey.com>
Sun, 15 Oct 2023 19:33:45 +0000 (13:33 -0600)
committerTom Tromey <tom@tromey.com>
Wed, 29 Nov 2023 21:29:44 +0000 (14:29 -0700)
gdbsupport/scope-exit.h has a couple of comments about being able to
rely on copy elision in C++17.  This patch makes the change.

Approved-By: Pedro Alves <pedro@palves.net>
gdbsupport/scope-exit.h

index cb8d92558697016886021df31de30e7787c4912b..8fa40b1ca8a5d4f95f5d517729cf17f2ad66d738 100644 (file)
@@ -69,16 +69,7 @@ public:
       }
   }
 
-  /* This is needed for make_scope_exit because copy elision isn't
-     guaranteed until C++17.  An optimizing compiler will usually skip
-     calling this, but it must exist.  */
-  scope_exit_base (const scope_exit_base &other)
-    : m_released (other.m_released)
-  {
-    other.m_released = true;
-  }
-
-  void operator= (const scope_exit_base &) = delete;
+  DISABLE_COPY_AND_ASSIGN (scope_exit_base);
 
   /* If this is called, then the wrapped function will not be called
      on destruction.  */
@@ -132,16 +123,7 @@ public:
     rhs.release ();
   }
 
-  /* This is needed for make_scope_exit because copy elision isn't
-     guaranteed until C++17.  An optimizing compiler will usually skip
-     calling this, but it must exist.  */
-  scope_exit (const scope_exit &other)
-    : scope_exit_base<scope_exit<EF>> (other),
-      m_exit_function (other.m_exit_function)
-  {
-  }
-
-  void operator= (const scope_exit &) = delete;
+  DISABLE_COPY_AND_ASSIGN (scope_exit);
   void operator= (scope_exit &&) = delete;
 
 private: