Add lttng::make_unique
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 12 May 2022 18:24:07 +0000 (14:24 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 13 Jun 2022 20:34:46 +0000 (16:34 -0400)
Add an equivalent to std::make_unique introduced in C++14.

See https://herbsutter.com/gotw/_102/ for more details.

Change-Id: I67e5b54d883e311869d7c1272f9a2905dc349212
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/common/Makefile.am
src/common/make-unique.hpp [new file with mode: 0644]

index 4df84d6985b3ceff88b90850d70970b80cd9d9e0..23d33e983b19bb3288c9edd565e29c6d2c9a4e31 100644 (file)
@@ -89,6 +89,7 @@ libcommon_lgpl_la_SOURCES = \
        kernel-probe.cpp \
        location.cpp \
        log-level-rule.cpp \
+       make-unique.hpp \
        make-unique-wrapper.hpp \
        mi-lttng.cpp mi-lttng.hpp \
        notification.cpp \
diff --git a/src/common/make-unique.hpp b/src/common/make-unique.hpp
new file mode 100644 (file)
index 0000000..244cd9e
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2022 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_MAKE_UNIQUE_H
+#define LTTNG_MAKE_UNIQUE_H
+
+#include <memory>
+
+namespace lttng {
+
+template <typename Type, typename... Args>
+std::unique_ptr<Type> make_unique(Args&&...args)
+{
+       return std::unique_ptr<Type>(new Type(std::forward<Args>(args)...));
+}
+
+} /* namespace lttng */
+
+#endif /* LTTNG_MAKE_UNIQUE_H */
This page took 0.027274 seconds and 5 git commands to generate.