From ab3bed93f8d6270a24b4a12bd5c19dcf5b0f61c6 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Fri, 1 Mar 2024 10:42:13 -0500 Subject: [PATCH] cpp-common/bt2c: use `ComparableWithCStringView` on `operator!=` meant for `CStringView` I don't recall exactly when I needed this, but it occured to me once that the `operator!=` we provide for `CStringView` was getting picked up for some unrelated type. It just seems dangerous to provide a generic templated operator like that that can match literally anything. Use the same `ComparableWithCStringView` conditions here that we use for `operator==` just above, so that it only gets used for what it was intended for. Change-Id: I798f1c8195c541f6188499dcfabfe1233a95a492 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/11962 Tested-by: jenkins Reviewed-by: Philippe Proulx --- src/cpp-common/bt2c/c-string-view.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cpp-common/bt2c/c-string-view.hpp b/src/cpp-common/bt2c/c-string-view.hpp index b1a7b6e7..3dca0299 100644 --- a/src/cpp-common/bt2c/c-string-view.hpp +++ b/src/cpp-common/bt2c/c-string-view.hpp @@ -240,7 +240,10 @@ bool operator==(LhsT&& lhs, RhsT&& rhs) noexcept * * Both `lhs` and `rhs` must not have an underlying `nullptr` raw data. */ -template +template < + typename LhsT, typename RhsT, + typename = typename std::enable_if::value>::type, + typename = typename std::enable_if::value>::type> bool operator!=(LhsT&& lhs, RhsT&& rhs) noexcept { return !(std::forward(lhs) == std::forward(rhs)); -- 2.34.1