[libsigcplusplus] Use just one TupleVisitorVisitEach instead of having 2 identical.



commit 87c840bccc3230f7b9ffac90e5d17eccab698f65
Author: Murray Cumming <murrayc murrayc com>
Date:   Wed Apr 13 13:04:29 2016 +0200

    Use just one TupleVisitorVisitEach instead of having 2 identical.
    
    Just to avoid the copy/pasting even of this small amount of code.

 sigc++/adaptors/bind.h                     |   21 +++------------------
 sigc++/adaptors/track_obj.h                |   14 ++------------
 sigc++/adaptors/tuple_visitor_visit_each.h |   28 ++++++++++++++++++++++++++++
 sigc++/filelist.am                         |    1 +
 4 files changed, 34 insertions(+), 30 deletions(-)
---
diff --git a/sigc++/adaptors/bind.h b/sigc++/adaptors/bind.h
index e055a4f..d92065c 100644
--- a/sigc++/adaptors/bind.h
+++ b/sigc++/adaptors/bind.h
@@ -2,12 +2,13 @@
 #define _SIGC_ADAPTORS_BIND_H_
 #include <sigc++/adaptors/adaptor_trait.h>
 #include <sigc++/adaptors/bound_argument.h>
-#include <tuple>
+#include <sigc++/adaptors/tuple_visitor_visit_each.h>
 #include <sigc++/tuple-utils/tuple_for_each.h>
 #include <sigc++/tuple-utils/tuple_start.h>
 #include <sigc++/tuple-utils/tuple_end.h>
 #include <sigc++/tuple-utils/tuple_transform_each.h>
 
+
 namespace sigc
 {
 
@@ -208,22 +209,6 @@ private:
   }
 };
 
-namespace
-{
-
-// TODO: Avoid duplication with TrackObjVisitForEach in track_obj.h
-template <typename T_element>
-struct TupleVisitorVisitEach
-{
-  template <typename T_action>
-  constexpr static void visit(const T_element& element, T_action&& action)
-  {
-    sigc::visit_each(std::forward<T_action>(action), element);
-  }
-};
-
-} // anonymous namespace
-
 #ifndef DOXYGEN_SHOULD_SKIP_THIS
 // template specialization of visitor<>::do_visit_each<>(action, functor):
 /** Performs a functor on each of the targets of a functor.
@@ -260,7 +245,7 @@ struct visitor<bind_functor<-1, T_functor, T_type...>>
   {
     sigc::visit_each(_A_action, _A_target.functor_);
 
-    sigc::internal::tuple_for_each<TupleVisitorVisitEach>(_A_target.bound_, _A_action);
+    sigc::internal::tuple_for_each<internal::TupleVisitorVisitEach>(_A_target.bound_, _A_action);
   }
 };
 
diff --git a/sigc++/adaptors/track_obj.h b/sigc++/adaptors/track_obj.h
index d3edd9e..e513254 100644
--- a/sigc++/adaptors/track_obj.h
+++ b/sigc++/adaptors/track_obj.h
@@ -2,6 +2,7 @@
 #define _SIGC_ADAPTORS_TRACK_OBJ_H_
 
 #include <sigc++/adaptors/adaptor_trait.h>
+#include <sigc++/adaptors/tuple_visitor_visit_each.h>
 #include <sigc++/limit_reference.h>
 #include <sigc++/tuple-utils/tuple_for_each.h>
 
@@ -110,19 +111,8 @@ struct visitor<track_obj_functor<T_functor, T_obj...>>
 
     // Call sigc::visit_each(_A_action, element) on each element in the
     //_A_target.obj_ tuple:
-    sigc::internal::tuple_for_each<TrackObjVisitForEach>(_A_target.obj_, _A_action);
+    sigc::internal::tuple_for_each<internal::TupleVisitorVisitEach>(_A_target.obj_, _A_action);
   }
-
-private:
-  template <typename T_element>
-  struct TrackObjVisitForEach
-  {
-    template <typename T_action>
-    constexpr static void visit(const T_element& element, T_action&& action)
-    {
-      sigc::visit_each(std::forward<T_action>(action), element);
-    }
-  };
 };
 #endif // DOXYGEN_SHOULD_SKIP_THIS
 
diff --git a/sigc++/adaptors/tuple_visitor_visit_each.h b/sigc++/adaptors/tuple_visitor_visit_each.h
new file mode 100644
index 0000000..b556a6a
--- /dev/null
+++ b/sigc++/adaptors/tuple_visitor_visit_each.h
@@ -0,0 +1,28 @@
+#ifndef _SIGC_TUPLE_VISITOR_VISIT_EACH_H_
+#define _SIGC_TUPLE_VISITOR_VISIT_EACH_H_
+
+#include <tuple>
+
+namespace sigc
+{
+
+namespace internal
+{
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+template <typename T_element>
+struct TupleVisitorVisitEach
+{
+  template <typename T_action>
+  constexpr static void visit(const T_element& element, T_action&& action)
+  {
+    sigc::visit_each(std::forward<T_action>(action), element);
+  }
+};
+#endif // DOXYGEN_SHOULD_SKIP_THIS
+
+} // namespace internal
+
+} // namespace sigc
+
+#endif /* _SIGC_TUPLE_VISITOR_VISIT_EACH_H_ */
diff --git a/sigc++/filelist.am b/sigc++/filelist.am
index 75ce246..134f0df 100644
--- a/sigc++/filelist.am
+++ b/sigc++/filelist.am
@@ -47,6 +47,7 @@ sigc_public_h =                               \
        adaptors/retype.h \
        adaptors/track_obj.h \
        adaptors/retype_return.h \
+       adaptors/tuple_visitor_visit_each.h \
        functors/functor_base.h \
        functors/functor_trait.h                \
        functors/functors.h             \


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