From fa447211d316bba4342402d754d71baba9fad671 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Wed, 31 Jan 2024 17:37:49 -0500 Subject: [PATCH] cpp-common/bt2s: use a `using` declaration This is exactly the purpose of a `using` declaration, to make the symbol from the `bpstd`/`nonstd` namespace accessible for unqualified lookup as if declared in the `bt2s` namespace. The code is much simpler. Signed-off-by: Philippe Proulx Change-Id: I8348f409a463b85f5b2ed1f1fd8f61adb404a6d9 Reviewed-on: https://review.lttng.org/c/babeltrace/+/11727 Tested-by: jenkins CI-Build: Simon Marchi --- src/cpp-common/bt2s/optional.hpp | 53 +++++------------------------ src/cpp-common/bt2s/string-view.hpp | 12 +++---- 2 files changed, 14 insertions(+), 51 deletions(-) diff --git a/src/cpp-common/bt2s/optional.hpp b/src/cpp-common/bt2s/optional.hpp index 96d003df..13f121c0 100644 --- a/src/cpp-common/bt2s/optional.hpp +++ b/src/cpp-common/bt2s/optional.hpp @@ -11,50 +11,15 @@ namespace bt2s { -template -using optional = nonstd::optional; - -using nullopt_t = nonstd::nullopt_t; -using bad_optional_access = nonstd::bad_optional_access; -constexpr nullopt_t nullopt {nonstd::nullopt}; - -template -constexpr optional::type> make_optional(T&& value) -{ - return nonstd::make_optional(std::forward(value)); -} - -template -constexpr optional make_optional(ArgTs&&...args) -{ - return nonstd::make_optional(std::forward(args)...); -} - -using in_place_t = nonstd::in_place_t; - -template -inline in_place_t in_place() -{ - return nonstd::in_place(); -} - -template -inline in_place_t in_place() -{ - return nonstd::in_place(); -} - -template -inline in_place_t in_place_type() -{ - return nonstd::in_place_type(); -} - -template -inline in_place_t in_place_index() -{ - return nonstd::in_place_index(); -} +using nonstd::optional; +using nonstd::nullopt_t; +using nonstd::bad_optional_access; +using nonstd::nullopt; +using nonstd::make_optional; +using nonstd::in_place_t; +using nonstd::in_place; +using nonstd::in_place_type; +using nonstd::in_place_index; } /* namespace bt2s */ diff --git a/src/cpp-common/bt2s/string-view.hpp b/src/cpp-common/bt2s/string-view.hpp index 8cdafd84..d3516376 100644 --- a/src/cpp-common/bt2s/string-view.hpp +++ b/src/cpp-common/bt2s/string-view.hpp @@ -11,13 +11,11 @@ namespace bt2s { -template > -using basic_string_view = bpstd::basic_string_view; - -using string_view = bpstd::string_view; -using wstring_view = bpstd::wstring_view; -using u16string_view = bpstd::u16string_view; -using u32string_view = bpstd::u32string_view; +using bpstd::basic_string_view; +using bpstd::string_view; +using bpstd::wstring_view; +using bpstd::u16string_view; +using bpstd::u32string_view; } /* namespace bt2s */ -- 2.34.1