Browse Source

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

master
roker 1 year ago
parent
commit
23d25ef428
1 changed files with 20 additions and 12 deletions
  1. +20
    -12
      src/wrapper.hh

+ 20
- 12
src/wrapper.hh View File

@ -29,9 +29,16 @@ public:
~Wrapper();
Wrapper<T> copy() const;
friend
bool operator==(const Wrapper<T>& a, const Wrapper<T>& b);
bool operator==(const Wrapper<T>& b) const
{
return value==b.value;
}
bool operator!=(const Wrapper<T>& 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<T*>& b) const
{
return value==b.value;
}
bool operator!=(const Wrapper<T*>& 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<T*>& a, const Wrapper<T*>& b);
protected:
@ -97,12 +111,6 @@ protected:
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


Loading…
Cancel
Save