Add make_unique_wrapper()
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 28 Apr 2022 15:28:15 +0000 (11:28 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 13 Jun 2022 20:34:46 +0000 (16:34 -0400)
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


No differences found
This page took 0.028321 seconds and 4 git commands to generate.