X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fmake-unique-wrapper.hpp;h=a0a4b541a2fd64bc7c01da8babd6b5c01bb54d5c;hb=d83ba9baef029eedf530d272d95487e9c59d4226;hp=9381ce9711d2b57a257310bc52217d239995fc13;hpb=28f23191dcbf047429d51950a337a57d7a3f866a;p=lttng-tools.git diff --git a/src/common/make-unique-wrapper.hpp b/src/common/make-unique-wrapper.hpp index 9381ce971..a0a4b541a 100644 --- a/src/common/make-unique-wrapper.hpp +++ b/src/common/make-unique-wrapper.hpp @@ -34,13 +34,13 @@ namespace lttng { * create_my_c_struct()); * * Note that this facility is intended for use in the scope of a function. - * If you need to return this unique_ptr instance, you should consider writting + * If you need to return this unique_ptr instance, you should consider writing * a proper, idiomatic, wrapper. */ -namespace details { +namespace memory { template -struct create_unique_class { +struct create_deleter_class { struct deleter { void operator()(WrappedType *instance) const { @@ -53,7 +53,6 @@ struct create_unique_class { return std::unique_ptr(instance); } }; -} /* namespace details */ /* * 'free' is a utility function for use with make_unique_wrapper. It makes it easier to @@ -66,13 +65,14 @@ void free(Type *ptr) { std::free(ptr); } +} /* namespace memory */ template std::unique_ptr::deleter> -make_unique_wrapper(WrappedType *instance) + typename memory::create_deleter_class::deleter> +make_unique_wrapper(WrappedType *instance = nullptr) { - const details::create_unique_class unique_deleter; + const memory::create_deleter_class unique_deleter; return unique_deleter(instance); }