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<struct foo *,
lttng::free>(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<lttng_session,
lttng::free>(nullptr));
Adding a default nullptr argument cuts down a bit of boiler plate.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I9d05d8162d28cc156b1e9ec6fe623f1cc02e9c8e
template <typename WrappedType, void (*DeleterFunc)(WrappedType *)>
std::unique_ptr<WrappedType,
typename memory::create_deleter_class<WrappedType, DeleterFunc>::deleter>
-make_unique_wrapper(WrappedType *instance)
+make_unique_wrapper(WrappedType *instance = nullptr)
{
const memory::create_deleter_class<WrappedType, DeleterFunc> unique_deleter;