Add make_unique_wrapper()
make_unique_wrapper is intended to facilitate the use of std::unique_ptr
to wrap C-style APIs that don't provide RAII resource management facilities.
Usage example:
// API
struct my_c_struct {
// ...
};
struct my_c_struct *create_my_c_struct(void);
void destroy_my_c_struct(struct my_c_struct *value);
// Creating a unique_ptr to my_c_struct.
auto safe_c_struct =
lttng::make_unique_wrapper<my_c_struct, destroy_my_c_struct>(
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
a proper, idiomatic, wrapper.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I429fc6f62896efb04af95fc26143096043206265
This page took 0.024967 seconds and 4 git commands to generate.