From: Jérémie Galarneau Date: Sat, 4 Feb 2023 00:24:54 +0000 (-0500) Subject: common: Add a default nullptr argument to make_unique_wrapper X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=799462ffd674d972289608c72b3f271a5839677a;p=lttng-tools.git common: Add a default nullptr argument to make_unique_wrapper 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 --- 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;