Add lttng::make_unique
[lttng-tools.git] / src / common / make-unique.hpp
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.02388 seconds and 4 git commands to generate.