From 118ea5da764d581e29d944744a114a25bcb81db9 Mon Sep 17 00:00:00 2001 From: Henner Zeller Date: Tue, 10 Oct 2023 12:08:33 -0700 Subject: [PATCH] C++20 preparation: make operator != non-ambiguous. C++20 auto-generates the != operator from ==. However, if that operator accepts a potentiallly different type, this might result in an ambiguous operator (-Wambiguous-reversed-operator). This provides the explicitly defined operator. --- common/util/tree_operations_test.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/common/util/tree_operations_test.cc b/common/util/tree_operations_test.cc index 33d1160178..545a57cba3 100644 --- a/common/util/tree_operations_test.cc +++ b/common/util/tree_operations_test.cc @@ -143,6 +143,7 @@ class SimpleNode { void set_id(std::string&& new_id) { id_ = new_id; } bool operator==(const ThisType& other) const { return this == &other; } + bool operator!=(const ThisType& other) const { return !(*this == other); } friend std::ostream& operator<<(std::ostream& stream, const ThisType& self) { self.PrintRecursively(stream, 0);