diff --git a/ChangeLog b/ChangeLog
index edf027f..a9e278a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2010-08-10  David Kozub  <zub@linux.fjfi.cvut.cz>
+
+	RefPtr: Add relational operators to make RefPtr
+	work with sorted containers (e.g. std::set<RefPtr<T> >).
+
+	* glib/glibmm/refptr.h: Add operators <, <=, >, >=
+	that compare RefPtrs by their underlying pointer.
+
 2010-08-10  José Alburquerque  <jaalburqu@svn.gnome.org>
 
 	giomm: Use ifdef in _WRAP_METHOD()s surrounded by #ifdefs.
diff --git a/glib/glibmm/refptr.h b/glib/glibmm/refptr.h
index b262edd..f6312f0 100644
--- a/glib/glibmm/refptr.h
+++ b/glib/glibmm/refptr.h
@@ -155,6 +155,26 @@ public:
   template <class T_CastFrom>
   static inline RefPtr<T_CppObject> cast_const(const RefPtr<T_CastFrom>& src);
 
+  /** Compare based on the underlying instance address.
+   *
+   * This is needed in code that requires an ordering on
+   * RefPtr<T_CppObject> instances, e.g. std::set<RefPtr<T_CppObject> >.
+   *
+   * Without these, comparing two RefPtr<T_CppObject> instances
+   * is still syntactically possible, but the result is semantically
+   * wrong, as p1 REL_OP p2 is interpreted as (bool)p1 REL_OP (bool)p2.
+   */
+  inline bool operator<(const RefPtr<T_CppObject>& src) const;
+
+  /// See operator<().
+  inline bool operator<=(const RefPtr<T_CppObject>& src) const;
+
+  /// See operator<().
+  inline bool operator>(const RefPtr<T_CppObject>& src) const;
+
+  /// See operator<().
+  inline bool operator>=(const RefPtr<T_CppObject>& src) const;
+
 private:
   T_CppObject* pCppObject_;
 };
@@ -338,6 +358,30 @@ RefPtr<T_CppObject> RefPtr<T_CppObject>::cast_const(const RefPtr<T_CastFrom>& sr
   return RefPtr<T_CppObject>(pCppObject);
 }
 
+template <class T_CppObject> inline
+bool RefPtr<T_CppObject>::operator<(const RefPtr<T_CppObject>& src) const
+{
+  return (pCppObject_ < src.pCppObject_);
+}
+
+template <class T_CppObject> inline
+bool RefPtr<T_CppObject>::operator<=(const RefPtr<T_CppObject>& src) const
+{
+  return (pCppObject_ <= src.pCppObject_);
+}
+
+template <class T_CppObject> inline
+bool RefPtr<T_CppObject>::operator>(const RefPtr<T_CppObject>& src) const
+{
+  return (pCppObject_ > src.pCppObject_);
+}
+
+template <class T_CppObject> inline
+bool RefPtr<T_CppObject>::operator>=(const RefPtr<T_CppObject>& src) const
+{
+  return (pCppObject_ >= src.pCppObject_);
+}
+
 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
 
 /** @relates Glib::RefPtr */
