[libsigc++2/variadic_bind4: 6/18] track_obj.h: Use this as a normal .h file.



commit 42fe3562dff89cfa71bdc8ae097474387c248dbb
Author: Murray Cumming <murrayc murrayc com>
Date:   Thu Jan 14 21:44:15 2016 +0100

    track_obj.h: Use this as a normal .h file.
    
    Instead of genrating it from a .h.m4 file.

 sigc++/.gitignore                                  |    1 -
 sigc++/adaptors/macros/bind.h.m4                   |   10 ++---
 .../{macros/track_obj.h.m4 => track_obj.h}         |   38 +++++--------------
 sigc++/filelist.am                                 |    7 ++--
 tests/test_bind_ref.cc                             |    2 +-
 5 files changed, 18 insertions(+), 40 deletions(-)
---
diff --git a/sigc++/.gitignore b/sigc++/.gitignore
index e375f77..384ef53 100644
--- a/sigc++/.gitignore
+++ b/sigc++/.gitignore
@@ -1,5 +1,4 @@
 /limit_reference.h
 /adaptors/bind.h
 /adaptors/retype.h
-/adaptors/track_obj.h
 /functors/mem_fun.h
diff --git a/sigc++/adaptors/macros/bind.h.m4 b/sigc++/adaptors/macros/bind.h.m4
index 469fc73..a88e4b1 100644
--- a/sigc++/adaptors/macros/bind.h.m4
+++ b/sigc++/adaptors/macros/bind.h.m4
@@ -329,16 +329,14 @@ FOR(1,CALL_SIZE,[[BIND_FUNCTOR_COUNT(%1)]])dnl
  *
  * @ingroup bind
  */
-template <int I_location, class T_bound1, class T_functor>
+template <int I_location, class T_functor, class... T_bound>
 inline decltype(auto)
-bind(const T_functor& _A_func, T_bound1 _A_b1)
+bind(const T_functor& _A_func, T_bound... _A_b)
 {
-  return bind_functor<I_location, T_functor, T_bound1>
-           (_A_func, _A_b1);
+  return bind_functor<I_location, T_functor, T_bound...>
+           (_A_func, _A_b...);
 }
 
-
-
 /** Creates an adaptor of type sigc::bind_functor which fixes the last arguments of the passed functor.
  * This function overload fixes the last arguments of @e _A_func.
  *
diff --git a/sigc++/adaptors/macros/track_obj.h.m4 b/sigc++/adaptors/track_obj.h
similarity index 78%
rename from sigc++/adaptors/macros/track_obj.h.m4
rename to sigc++/adaptors/track_obj.h
index a7a1f36..2816054 100644
--- a/sigc++/adaptors/macros/track_obj.h.m4
+++ b/sigc++/adaptors/track_obj.h
@@ -1,27 +1,6 @@
-dnl Copyright 2013, The libsigc++ Development Team
-dnl
-dnl This file is part of libsigc++.
-dnl
-dnl This library is free software; you can redistribute it and/or
-dnl modify it under the terms of the GNU Lesser General Public
-dnl License as published by the Free Software Foundation; either
-dnl version 2.1 of the License, or (at your option) any later version.
-dnl
-dnl This library is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-dnl Lesser General Public License for more details.
-dnl
-dnl You should have received a copy of the GNU Lesser General Public
-dnl License along with this library. If not, see <http://www.gnu.org/licenses/>.
-dnl
-divert(-1)
-
-include(template.macros.m4)
-
-
-divert(0)dnl
-_FIREWALL([ADAPTORS_TRACK_OBJ])
+#ifndef _SIGC_ADAPTORS_TRACK_OBJ_H_
+#define _SIGC_ADAPTORS_TRACK_OBJ_H_
+
 #include <sigc++/adaptors/adaptor_trait.h>
 #include <sigc++/limit_reference.h>
 #include <sigc++/tuple_for_each.h>
@@ -36,7 +15,7 @@ namespace sigc {
  *
  * The functor returned by sigc::track_obj() is formally an adaptor, but it does
  * not alter the signature, return type or behaviour of the supplied functor.
- * Up to CALL_SIZE objects can be tracked. operator()() can have up to CALL_SIZE arguments.
+ * Up to 7 objects can be tracked. operator()() can have up to 7 arguments.
  *
  * @par Example:
  * @code
@@ -45,9 +24,9 @@ namespace sigc {
  * void foo(bar&);
  * {
  *   bar some_bar;
- *   some_signal.connect([[&some_bar]](){ foo(some_bar); });
+ *   some_signal.connect([&some_bar](){ foo(some_bar); });
  *     // NOT disconnected automatically when some_bar goes out of scope
- *   some_signal.connect(sigc::track_obj([[&some_bar]](){ foo(some_bar); }, some_bar);
+ *   some_signal.connect(sigc::track_obj([&some_bar](){ foo(some_bar); }, some_bar);
  *     // disconnected automatically when some_bar goes out of scope
  * }
  * @endcode
@@ -136,9 +115,10 @@ struct visitor<track_obj_functor<T_functor, T_obj...>>
   }
 
 private:
-  template<typename T_element, typename T_action>
+  template<typename T_element>
   struct TrackObjVisitForEach
   {
+    template<typename T_action>
     static
     void
     visit(const T_element& element, const T_action& action)
@@ -169,3 +149,5 @@ track_obj(const T_functor& _A_func, const T_obj&... _A_obj)
 
 
 } /* namespace sigc */
+
+#endif /* _SIGC_ADAPTORS_TRACK_OBJ_H_ */
diff --git a/sigc++/filelist.am b/sigc++/filelist.am
index f073570..67bc133 100644
--- a/sigc++/filelist.am
+++ b/sigc++/filelist.am
@@ -27,12 +27,10 @@ functors_built_h = mem_fun.h
 
 # Adaptors (adaptors/)
 adaptors_m4 = bind.h.m4 \
-             retype.h.m4 \
-             track_obj.h.m4
+             retype.h.m4
 adaptors_built_cc =
 adaptors_built_h = bind.h \
-                   retype.h \
-                   track_obj.h
+                   retype.h
 
 # Combine all the above parts with right directories prefixed
 sigc_m4 = $(base_m4:%=macros/%) \
@@ -71,6 +69,7 @@ sigc_public_h =                               \
        adaptors/compose.h \
        adaptors/exception_catch.h \
        adaptors/hide.h \
+       adaptors/track_obj.h \
        adaptors/retype_return.h \
        functors/functor_trait.h                \
        functors/functors.h             \
diff --git a/tests/test_bind_ref.cc b/tests/test_bind_ref.cc
index d8ea53b..f3e11c6 100644
--- a/tests/test_bind_ref.cc
+++ b/tests/test_bind_ref.cc
@@ -54,7 +54,7 @@ int main(int argc, char* argv[])
     Param param("murrayc");
     // A convoluted way to do
     // slot_bound = sigc::bind(slot_full, std::ref(param));
-    slot_bound = sigc::bind< -1, std::reference_wrapper<Param> >(slot_full, std::ref(param));
+    slot_bound = sigc::bind< -1, decltype(slot_full), std::reference_wrapper<Param> >(slot_full, 
std::ref(param));
 
     result_stream << "Calling slot when param exists:";
     slot_bound();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]