From 7a695d8a82eaaa7db0cf4484b22fc3db3d43ac49 Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Fri, 5 Jun 2020 23:33:24 +0300 Subject: fix compilation with VS2019, preview of 16.7 version Compiler tells something about argument-dependent lookup. I do not understand how that ADL works. But I know that such operators should be free functions, instead of methods: http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Ro-symmetric Such syntax defines 'friend' free functions. --- include/ilist.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/ilist.h b/include/ilist.h index 5d0a425a9cc..722677f9057 100644 --- a/include/ilist.h +++ b/include/ilist.h @@ -99,8 +99,14 @@ public: reference operator*() { return *static_cast(node_); } pointer operator->() { return static_cast(node_); } - bool operator==(const Iterator &rhs) { return node_ == rhs.node_; } - bool operator!=(const Iterator &rhs) { return !(*this == rhs); } + friend bool operator==(const Iterator &lhs, const Iterator &rhs) + { + return lhs.node_ == rhs.node_; + } + friend bool operator!=(const Iterator &lhs, const Iterator &rhs) + { + return !(lhs == rhs); + } private: ListNode *node_; -- cgit v1.2.1