From: Jérémie Galarneau Date: Thu, 12 May 2022 18:24:07 +0000 (-0400) Subject: Add lttng::make_unique X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=1823e905abb7044e38434cc7d16fdec8545dda1c;p=deliverable%2Flttng-tools.git Add lttng::make_unique 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 --- diff --git a/src/common/Makefile.am b/src/common/Makefile.am index 4df84d698..23d33e983 100644 --- a/src/common/Makefile.am +++ b/src/common/Makefile.am @@ -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 index 000000000..244cd9e7b --- /dev/null +++ b/src/common/make-unique.hpp @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2022 Jérémie Galarneau + * + * SPDX-License-Identifier: LGPL-2.1-only + * + */ + +#ifndef LTTNG_MAKE_UNIQUE_H +#define LTTNG_MAKE_UNIQUE_H + +#include + +namespace lttng { + +template +std::unique_ptr make_unique(Args&&...args) +{ + return std::unique_ptr(new Type(std::forward(args)...)); +} + +} /* namespace lttng */ + +#endif /* LTTNG_MAKE_UNIQUE_H */