Browse Source

G++ does not like "non-template functions as friends of class templates. So I change the operator== into member function. :-|

master
roker 4 years ago
parent
commit
23d25ef428
  1. 32
      src/wrapper.hh

32
src/wrapper.hh

@ -29,9 +29,16 @@ public:
~Wrapper(); ~Wrapper();
Wrapper<T> copy() const; Wrapper<T> copy() const;
friend bool operator==(const Wrapper<T>& b) const
bool operator==(const Wrapper<T>& a, const Wrapper<T>& b); {
return value==b.value;
}
bool operator!=(const Wrapper<T>& b) const
{
return value!=b.value;
}
private: private:
// must be defined for each wrapped type: // must be defined for each wrapped type:
@ -78,11 +85,18 @@ public:
_free(value); _free(value);
} }
bool operator==(const Wrapper<T*>& b) const
{
return value==b.value;
}
bool operator!=(const Wrapper<T*>& b) const
{
return value!=b.value;
}
const T* get() const { return value; } const T* get() const { return value; }
T* move_out() { T* r = value; value=nullptr; return r;} T* move_out() { T* r = value; value=nullptr; return r;}
friend
bool operator==(const Wrapper<T*>& a, const Wrapper<T*>& b);
protected: protected:
@ -97,12 +111,6 @@ protected:
T* value; T* value;
}; };
template<class T>
inline
bool operator!=(const Wrapper<T>& a, const Wrapper<T>& b)
{
return !(a==b);
}
// Wraps single-linked lists and provides an interface compatible // Wraps single-linked lists and provides an interface compatible

Loading…
Cancel
Save