From 799462ffd674d972289608c72b3f271a5839677a Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Fri, 3 Feb 2023 19:24:54 -0500 Subject: [PATCH] common: Add a default nullptr argument to make_unique_wrapper MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit When wrapping C libraries that return unmanaged pointers, lttng::make_unique_wrapper makes it easier to locally "wrap" returned pointers. auto val = lttng::make_unique_ptr(some_func()); However, in its current form, a nullptr must be passed to define an alias: using my_type_uptr = decltype(lttng::make_unique_wrapper(nullptr)); Adding a default nullptr argument cuts down a bit of boiler plate. Signed-off-by: Jérémie Galarneau Change-Id: I9d05d8162d28cc156b1e9ec6fe623f1cc02e9c8e --- src/common/make-unique-wrapper.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/make-unique-wrapper.hpp b/src/common/make-unique-wrapper.hpp index e49e5ced7..ebec2ca45 100644 --- a/src/common/make-unique-wrapper.hpp +++ b/src/common/make-unique-wrapper.hpp @@ -70,7 +70,7 @@ void free(Type *ptr) template std::unique_ptr::deleter> -make_unique_wrapper(WrappedType *instance) +make_unique_wrapper(WrappedType *instance = nullptr) { const memory::create_deleter_class unique_deleter; -- 2.34.1