? Doxyfile
? libsigc.kdevelop
? memfuntrackable.patch
? stamp-h1
? trackable.patch
? two_pointers.patch
? two_pointers_for_trackables.patch
? docs/manual/html
? tests/test_bind_ref
? tests/test_custom
Index: sigc++/type_traits.h
===================================================================
RCS file: /cvs/gnome/libsigc++2/sigc++/type_traits.h,v
retrieving revision 1.15
diff -u -p -r1.15 type_traits.h
--- sigc++/type_traits.h	25 Apr 2005 19:31:25 -0000	1.15
+++ sigc++/type_traits.h	27 Apr 2005 21:41:14 -0000
@@ -91,6 +91,23 @@ struct type_trait<void>
 /**
  * Compile-time determination of base-class relationship in C++
  * (adapted to match the syntax of boost's type_traits library).
+ *
+ * Use this to provide a template specialization for a set of types.
+ * For instance,
+ *
+ * template < class T_thing, bool Tval_derives_from_something = sigc::is_base_and_derived<Something, T_thing>::value >
+ * class TheTemplate
+ * {
+ *   //Standard implementation.
+ * }
+ *
+ * //Specialization for T_things that derive from Something (Tval_derives_from_something is true)
+ * template <class T_thing>
+ * class TheTemplate<T_thing, true>
+ * {
+ *   T_thing thing;
+     thing.method_that_is_in_something();
+ * }
  */
 template <class T_base, class T_derived>
 struct is_base_and_derived
Index: sigc++/functors/macros/mem_fun.h.m4
===================================================================
RCS file: /cvs/gnome/libsigc++2/sigc++/functors/macros/mem_fun.h.m4,v
retrieving revision 1.9
diff -u -p -r1.9 mem_fun.h.m4
--- sigc++/functors/macros/mem_fun.h.m4	1 Feb 2005 11:02:21 -0000	1.9
+++ sigc++/functors/macros/mem_fun.h.m4	27 Apr 2005 21:41:15 -0000
@@ -69,6 +69,7 @@ protected:
 
 ])
 define([BOUND_MEMBER_FUNCTOR],[dnl
+
 /** bound_[$2]mem_functor$1 encapsulates a $4 method with $1 arguments and an object instance.
  * Use the convenience function mem_fun() to create an instance of bound_[$2]mem_functor$1.
  *
@@ -80,7 +81,7 @@ FOR(1,$1,[
  *
  * @ingroup mem_fun
  */
-template <LIST(class T_return, class T_obj, LOOP(class T_arg%1, $1))>
+template <LIST(class T_return, class T_obj, LOOP(class T_arg%1, $1)), bool I_derives_trackable = is_base_and_derived<sigc::trackable, T_obj>::value>
 class bound_[$2]mem_functor$1
   : public [$2]mem_functor$1<LIST(T_return, T_obj, LOOP(T_arg%1, $1))>
 {
@@ -93,14 +94,18 @@ public:
    * @param _A_func Pointer to method will be invoked from operator()().
    */
   bound_[$2]mem_functor$1($3 T_obj* _A_obj, function_type _A_func)
-    : base_type_(_A_func), obj_ptr_(_A_obj) {}
+    : base_type_(_A_func),
+    obj_ptr_(_A_obj)
+    {}
 
   /** Constructs a bound_[$2]mem_functor$1 object that wraps the passed method.
    * @param _A_obj Reference to instance the method will operate on.
    * @param _A_func Pointer to method will be invoked from operator()().
    */
   bound_[$2]mem_functor$1($3 T_obj& _A_obj, function_type _A_func)
-    : base_type_(_A_func), obj_ptr_(&_A_obj) {}
+    : base_type_(_A_func),
+    obj_ptr_(&_A_obj)
+    {}
 
   /** Execute the wrapped method operating on the stored instance.dnl
 FOR(1, $1,[
@@ -111,8 +116,51 @@ FOR(1, $1,[
     { return (obj_ptr_->*(this->func_ptr_))(LOOP(_A_a%1, $1)); }
 
 //protected:
-  /// Pointer to stored object instance.
-  $3 T_obj *obj_ptr_;
+  // Pointer to stored object instance.
+  // This is the handler object, such as TheObject in void TheObject::signal_handler().
+  $3 T_obj *obj_ptr_; //This, and its type is used by the visit_each<> specialization below.
+};
+
+//Specialization for T_obj that derives from sigc::trackable.
+template <LIST(class T_return, class T_obj, LOOP(class T_arg%1, $1))>
+class bound_[$2]mem_functor$1<LIST(T_return, T_obj, LOOP(T_arg%1, $1), true)>
+  : public [$2]mem_functor$1<LIST(T_return, T_obj, LOOP(T_arg%1, $1))>
+{
+  typedef [$2]mem_functor$1<LIST(T_return, T_obj, LOOP(T_arg%1, $1))> base_type_;
+public:
+  typedef typename base_type_::function_type function_type;
+
+  /** Constructs a bound_[$2]mem_functor$1 object that wraps the passed method.
+   * @param _A_obj Pointer to instance the method will operate on.
+   * @param _A_func Pointer to method will be invoked from operator()().
+   */
+  bound_[$2]mem_functor$1($3 T_obj* _A_obj, function_type _A_func)
+    : base_type_(_A_func),
+      obj_ptr_derived_(_A_obj), obj_ptr_(_A_obj)
+    {}
+
+  /** Constructs a bound_[$2]mem_functor$1 object that wraps the passed method.
+   * @param _A_obj Reference to instance the method will operate on.
+   * @param _A_func Pointer to method will be invoked from operator()().
+   */
+  bound_[$2]mem_functor$1($3 T_obj& _A_obj, function_type _A_func)
+    : base_type_(_A_func),
+      obj_ptr_derived_(&_A_obj), obj_ptr_(&_A_obj)
+    {}
+
+  /** Execute the wrapped method operating on the stored instance.dnl
+FOR(1, $1,[
+   * @param _A_a%1 Argument to be passed on to the method.])
+   * @return The return value of the method invocation.
+   */
+  T_return operator()(LOOP(typename type_trait<T_arg%1>::take _A_a%1, $1)) const
+    { return ( (obj_ptr_derived_)->*(this->func_ptr_))(LOOP(_A_a%1, $1)); }
+
+//protected:
+  // Pointer to stored object instance.
+  // This is the handler object, such as TheObject in void TheObject::signal_handler().
+  $3 T_obj* obj_ptr_derived_;
+  $3 sigc::trackable* obj_ptr_; //This, and its type is used by the visit_each<> specialization below.
 };
 
 //template specialization of visit_each<>(action, functor):
@@ -180,6 +228,7 @@ divert(0)
 __FIREWALL__
 #include <sigc++/type_traits.h>
 #include <sigc++/functors/functor_trait.h>
+#include <sigc++/trackable.h>
 
 namespace sigc {
 
