2 * Copyright (c) 2022 Philippe Proulx <pproulx@efficios.com>
4 * SPDX-License-Identifier: MIT
7 #ifndef BABELTRACE_CPP_COMMON_MAKE_UNIQUE_HPP
8 #define BABELTRACE_CPP_COMMON_MAKE_UNIQUE_HPP
11 #include <type_traits>
14 namespace bt2_common {
17 * Our implementation of std::make_unique<>() for C++11.
19 template <typename T, typename... ArgTs>
20 std::unique_ptr<T> makeUnique(ArgTs&&...args)
22 static_assert(!std::is_array<T>::value, "`T` is not an array (unsupported).");
24 return std::unique_ptr<T>(new T {std::forward<ArgTs>(args)...});
27 } /* namespace bt2_common */
29 #endif /* BABELTRACE_CPP_COMMON_MAKE_UNIQUE_HPP */