From: Philippe Proulx Date: Wed, 15 Nov 2023 04:47:38 +0000 (-0500) Subject: cpp-common: rename bt2c::makeUnique() -> bt2s::make_unique() X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=80ab6559c42fadfbac0f131ba62a5984ffc945a0;p=babeltrace.git cpp-common: rename bt2c::makeUnique() -> bt2s::make_unique() I now want everything mimicking the STL stuff to have the same names, but I don't want to mix coding styles in `bt2c`. Therefore introduce this new `bt2s` (the `s` stands for `std`) namespace to contain everything acting as the STL (or Boost, if need be). Signed-off-by: Philippe Proulx Change-Id: Ie24c11170cc650028f3ce50fcab2004f0195c12f Reviewed-on: https://review.lttng.org/c/babeltrace/+/11393 CI-Build: Simon Marchi Reviewed-by: Simon Marchi Tested-by: jenkins --- diff --git a/src/Makefile.am b/src/Makefile.am index b5d24fe1..9f4796e4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -47,13 +47,13 @@ noinst_HEADERS = \ cpp-common/bt2c/glib-up.hpp \ cpp-common/bt2c/lib-str.hpp \ cpp-common/bt2c/libc-up.hpp \ - cpp-common/bt2c/make-unique.hpp \ cpp-common/bt2c/read-fixed-len-int.hpp \ cpp-common/bt2c/safe-ops.hpp \ cpp-common/bt2c/std-int.hpp \ cpp-common/bt2c/uuid-view.hpp \ cpp-common/bt2c/uuid.hpp \ cpp-common/bt2c/vector.hpp \ + cpp-common/bt2s/make-unique.hpp \ cpp-common/nlohmann/json.hpp \ cpp-common/optional.hpp \ cpp-common/string_view.hpp diff --git a/src/cpp-common/bt2c/make-unique.hpp b/src/cpp-common/bt2c/make-unique.hpp deleted file mode 100644 index 95f55340..00000000 --- a/src/cpp-common/bt2c/make-unique.hpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2022 Philippe Proulx - * - * SPDX-License-Identifier: MIT - */ - -#ifndef BABELTRACE_CPP_COMMON_BT2C_MAKE_UNIQUE_HPP -#define BABELTRACE_CPP_COMMON_BT2C_MAKE_UNIQUE_HPP - -#include -#include -#include - -namespace bt2c { - -/* - * Our implementation of std::make_unique<>() for C++11. - */ -template -std::unique_ptr makeUnique(ArgTs&&...args) -{ - static_assert(!std::is_array::value, "`T` is not an array (unsupported)."); - - return std::unique_ptr(new T {std::forward(args)...}); -} - -} /* namespace bt2c */ - -#endif /* BABELTRACE_CPP_COMMON_BT2C_MAKE_UNIQUE_HPP */ diff --git a/src/cpp-common/bt2s/make-unique.hpp b/src/cpp-common/bt2s/make-unique.hpp new file mode 100644 index 00000000..6c4d1bf7 --- /dev/null +++ b/src/cpp-common/bt2s/make-unique.hpp @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2022 Philippe Proulx + * + * SPDX-License-Identifier: MIT + */ + +#ifndef BABELTRACE_CPP_COMMON_BT2S_MAKE_UNIQUE_HPP +#define BABELTRACE_CPP_COMMON_BT2S_MAKE_UNIQUE_HPP + +#include +#include +#include + +namespace bt2s { + +/* + * Our implementation of std::make_unique<>() for C++11. + */ +template +std::unique_ptr make_unique(ArgTs&&...args) +{ + static_assert(!std::is_array::value, "`T` is not an array (unsupported)."); + + return std::unique_ptr(new T {std::forward(args)...}); +} + +} /* namespace bt2s */ + +#endif /* BABELTRACE_CPP_COMMON_BT2S_MAKE_UNIQUE_HPP */