From 5b2d3ebb80029d9f23862ca8e0f1863287d7d04e Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Thu, 19 May 2022 12:11:40 -0400 Subject: [PATCH] bt2::internal::BorrowedObj: use default copy operations explicitly 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 Change-Id: I4b4f19416a78ca05eaf3fa92f85f9637b2be2c0a Reviewed-on: https://review.lttng.org/c/babeltrace/+/8090 Reviewed-on: https://review.lttng.org/c/babeltrace/+/10801 Tested-by: jenkins --- src/cpp-common/bt2/internal/borrowed-obj.hpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/cpp-common/bt2/internal/borrowed-obj.hpp b/src/cpp-common/bt2/internal/borrowed-obj.hpp index 3d4abd37..9b68af96 100644 --- a/src/cpp-common/bt2/internal/borrowed-obj.hpp +++ b/src/cpp-common/bt2/internal/borrowed-obj.hpp @@ -38,7 +38,7 @@ class BorrowedObj /* * This makes it possible for a `BorrowedObj` * instance to get assigned an instance of - * `BorrowedObj` (copy constructor and assignment + * `BorrowedObj` ("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 -- 2.34.1