@@ -31,13 +31,10 @@ template<typename T> class wp;
3131
3232// ---------------------------------------------------------------------------
3333
34- #define COMPARE (_op_ ) \
34+ #define COMPARE_WEAK (_op_ ) \
3535inline bool operator _op_ (const sp<T>& o) const { \
3636 return m_ptr _op_ o.m_ptr ; \
3737} \
38- inline bool operator _op_ (const wp<T>& o) const { \
39- return m_ptr _op_ o.m_ptr ; \
40- } \
4138inline bool operator _op_ (const T* o) const { \
4239 return m_ptr _op_ o; \
4340} \
@@ -46,12 +43,18 @@ inline bool operator _op_ (const sp<U>& o) const { \
4643 return m_ptr _op_ o.m_ptr ; \
4744} \
4845template <typename U> \
49- inline bool operator _op_ (const wp<U>& o) const { \
46+ inline bool operator _op_ (const U* o) const { \
47+ return m_ptr _op_ o; \
48+ }
49+
50+ #define COMPARE (_op_ ) \
51+ COMPARE_WEAK (_op_) \
52+ inline bool operator _op_ (const wp<T>& o) const { \
5053 return m_ptr _op_ o.m_ptr ; \
5154} \
5255template <typename U> \
53- inline bool operator _op_ (const U* o) const { \
54- return m_ptr _op_ o; \
56+ inline bool operator _op_ (const wp<U>& o) const { \
57+ return m_ptr _op_ o. m_ptr ; \
5558}
5659
5760// ---------------------------------------------------------------------------
@@ -274,13 +277,43 @@ class wp
274277 inline T* unsafe_get () const { return m_ptr; }
275278
276279 // Operators
277-
278- COMPARE (==)
279- COMPARE (!=)
280- COMPARE (>)
281- COMPARE (<)
282- COMPARE (<=)
283- COMPARE (>=)
280+
281+ COMPARE_WEAK (==)
282+ COMPARE_WEAK (!=)
283+ COMPARE_WEAK (>)
284+ COMPARE_WEAK (<)
285+ COMPARE_WEAK (<=)
286+ COMPARE_WEAK (>=)
287+
288+ inline bool operator == (const wp<T>& o) const {
289+ return (m_ptr == o.m_ptr ) && (m_refs == o.m_refs );
290+ }
291+ template <typename U>
292+ inline bool operator == (const wp<U>& o) const {
293+ return m_ptr == o.m_ptr ;
294+ }
295+
296+ inline bool operator > (const wp<T>& o) const {
297+ return (m_ptr == o.m_ptr ) ? (m_refs > o.m_refs ) : (m_ptr > o.m_ptr );
298+ }
299+ template <typename U>
300+ inline bool operator > (const wp<U>& o) const {
301+ return (m_ptr == o.m_ptr ) ? (m_refs > o.m_refs ) : (m_ptr > o.m_ptr );
302+ }
303+
304+ inline bool operator < (const wp<T>& o) const {
305+ return (m_ptr == o.m_ptr ) ? (m_refs < o.m_refs ) : (m_ptr < o.m_ptr );
306+ }
307+ template <typename U>
308+ inline bool operator < (const wp<U>& o) const {
309+ return (m_ptr == o.m_ptr ) ? (m_refs < o.m_refs ) : (m_ptr < o.m_ptr );
310+ }
311+ inline bool operator != (const wp<T>& o) const { return m_refs != o.m_refs ; }
312+ template <typename U> inline bool operator != (const wp<U>& o) const { return !operator == (o); }
313+ inline bool operator <= (const wp<T>& o) const { return !operator > (o); }
314+ template <typename U> inline bool operator <= (const wp<U>& o) const { return !operator > (o); }
315+ inline bool operator >= (const wp<T>& o) const { return !operator < (o); }
316+ template <typename U> inline bool operator >= (const wp<U>& o) const { return !operator < (o); }
284317
285318private:
286319 template <typename Y> friend class sp ;
@@ -294,6 +327,7 @@ template <typename T>
294327TextOutput& operator <<(TextOutput& to, const wp<T>& val);
295328
296329#undef COMPARE
330+ #undef COMPARE_WEAK
297331
298332// ---------------------------------------------------------------------------
299333// No user serviceable parts below here.
0 commit comments