bt2::internal::BorrowedObj: use default copy operations explicitly
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 19 May 2022 16:11:40 +0000 (12:11 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Mon, 11 Sep 2023 15:24:02 +0000 (11:24 -0400)
What was called the generic copy constructor and assignment operator
are in fact constructor templates, not true copy operations.

This is because C++ requires that a copy constructor/assignment operator
be a "non-template non-static member function".

This patch is not a fix because the generated default copy operations
were fine (just copy the underlying libbabeltrace2 pointer). Just use
the default ones explicitly and fix the comments so that we know what's
going on.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I4b4f19416a78ca05eaf3fa92f85f9637b2be2c0a
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8090
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10801
Tested-by: jenkins <jenkins@lttng.org>
src/cpp-common/bt2/internal/borrowed-obj.hpp

index 3d4abd37b815decdc5c3c8ad06a16c4641f3bbaf..9b68af96967b8f43fe794719c05447d8db400d61 100644 (file)
@@ -38,7 +38,7 @@ class BorrowedObj
     /*
      * This makes it possible for a `BorrowedObj<const bt_something>`
      * instance to get assigned an instance of
-     * `BorrowedObj<bt_something>` (copy constructor and assignment
+     * `BorrowedObj<bt_something>` ("copy" constructor and "assignment"
      * operator).
      *
      * C++ forbids the other way around.
@@ -64,8 +64,12 @@ protected:
         BT_ASSERT(libObjPtr);
     }
 
+    /* Default copy operations */
+    BorrowedObj(const BorrowedObj&) noexcept = default;
+    BorrowedObj& operator=(const BorrowedObj&) noexcept = default;
+
     /*
-     * Generic copy constructor.
+     * Generic "copy" constructor.
      *
      * This converting constructor accepts both an instance of
      * `_ThisBorrowedObj` and an instance (`other`) of
@@ -82,7 +86,7 @@ protected:
     }
 
     /*
-     * Generic assignment operator.
+     * Generic "assignment" operator.
      *
      * This operator accepts both an instance of
      * `_ThisBorrowedObj` and an instance (`other`) of
This page took 0.027155 seconds and 4 git commands to generate.