From 23d25ef42898c03337d19d23b41707abe4929805 Mon Sep 17 00:00:00 2001 From: roker Date: Fri, 18 Jun 2021 18:30:58 +0200 Subject: [PATCH] G++ does not like "non-template functions as friends of class templates. So I change the operator== into member function. :-| --- src/wrapper.hh | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/wrapper.hh b/src/wrapper.hh index 6c80fe0..4344329 100644 --- a/src/wrapper.hh +++ b/src/wrapper.hh @@ -29,9 +29,16 @@ public: ~Wrapper(); Wrapper copy() const; - - friend - bool operator==(const Wrapper& a, const Wrapper& b); + + bool operator==(const Wrapper& b) const + { + return value==b.value; + } + + bool operator!=(const Wrapper& b) const + { + return value!=b.value; + } private: // must be defined for each wrapped type: @@ -78,11 +85,18 @@ public: _free(value); } + bool operator==(const Wrapper& b) const + { + return value==b.value; + } + + bool operator!=(const Wrapper& b) const + { + return value!=b.value; + } + const T* get() const { return value; } T* move_out() { T* r = value; value=nullptr; return r;} - - friend - bool operator==(const Wrapper& a, const Wrapper& b); protected: @@ -97,12 +111,6 @@ protected: T* value; }; -template -inline -bool operator!=(const Wrapper& a, const Wrapper& b) -{ - return !(a==b); -} // Wraps single-linked lists and provides an interface compatible