Add comparison operators to FbTk::RefCount

without them, gcc would compare them by converting them to bool first, which is not exactly what
one would expect. Frankly, I'm surprised it even worked without this.
This commit is contained in:
Pavel Labath 2011-07-25 15:39:41 +02:00
parent 536a16e6e2
commit 05b5974e62

View file

@ -152,6 +152,36 @@ inline RefCount<Pointer> makeRef(const Arg1 &arg1, const Arg2 &arg2, const Arg3
return RefCount<Pointer>(new Pointer(arg1, arg2, arg3));
}
template <typename Pointer, typename Pointer2>
inline bool operator == (const RefCount<Pointer> &a, const RefCount<Pointer2> &b) {
return a.get() == b.get();
}
template <typename Pointer, typename Pointer2>
inline bool operator != (const RefCount<Pointer> &a, const RefCount<Pointer2> &b) {
return a.get() != b.get();
}
template <typename Pointer, typename Pointer2>
inline bool operator < (const RefCount<Pointer> &a, const RefCount<Pointer2> &b) {
return a.get() < b.get();
}
template <typename Pointer, typename Pointer2>
inline bool operator > (const RefCount<Pointer> &a, const RefCount<Pointer2> &b) {
return a.get() > b.get();
}
template <typename Pointer, typename Pointer2>
inline bool operator <= (const RefCount<Pointer> &a, const RefCount<Pointer2> &b) {
return a.get() <= b.get();
}
template <typename Pointer, typename Pointer2>
inline bool operator >= (const RefCount<Pointer> &a, const RefCount<Pointer2> &b) {
return a.get() >= b.get();
}
} // end namespace FbTk
#endif // FBTK_REFCOUNT_HH