[libsigcplusplus] adaptor_trait.h: Move adapts<> into its own file.



commit 276098c1dac0a7755eebdae7654607b01aa65602
Author: Murray Cumming <murrayc murrayc com>
Date:   Wed Apr 13 20:37:34 2016 +0200

    adaptor_trait.h: Move adapts<> into its own file.
    
    To make it clearer what is used by what.

 sigc++/adaptors/adaptor_trait.h   |   83 ---------------------------------
 sigc++/adaptors/adapts.h          |   92 +++++++++++++++++++++++++++++++++++++
 sigc++/adaptors/bind.h            |    2 +-
 sigc++/adaptors/bind_return.h     |    2 +-
 sigc++/adaptors/compose.h         |    2 +-
 sigc++/adaptors/exception_catch.h |    2 +-
 sigc++/adaptors/hide.h            |    2 +-
 sigc++/adaptors/retype.h          |    2 +-
 sigc++/adaptors/retype_return.h   |    2 +-
 sigc++/adaptors/track_obj.h       |    2 +-
 sigc++/filelist.am                |    1 +
 tests/test_visit_each.cc          |    1 +
 12 files changed, 102 insertions(+), 91 deletions(-)
---
diff --git a/sigc++/adaptors/adaptor_trait.h b/sigc++/adaptors/adaptor_trait.h
index c6d5a86..a552d13 100644
--- a/sigc++/adaptors/adaptor_trait.h
+++ b/sigc++/adaptors/adaptor_trait.h
@@ -34,11 +34,6 @@
 namespace sigc
 {
 
-#ifndef DOXYGEN_SHOULD_SKIP_THIS
-template <class T_functor>
-struct adapts;
-#endif
-
 /** @defgroup adaptors Adaptors
  * Adaptors are functors that alter the signature of a functor's
  * operator()().
@@ -168,83 +163,5 @@ public:
   using adaptor_type = adaptor_functor<functor_type>;
 };
 
-// Doxygen (at least version 1.8.4) removes blank lines in a code block.
-// That's why there are empty comment lines in the following code block.
-/** Base type for adaptors.
- * sigc::adapts wraps adaptors, functors, function pointers and class methods.
- * It contains a single member functor which is always a sigc::adaptor_base.
- * The adaptor_type alias defines the exact type that is used
- * to store the adaptor, functor, function pointer or class method passed
- * into the constructor. It differs from @a T_functor unless @a T_functor
- * inherits from sigc::adaptor_base.
- *
- * @par Example of a simple adaptor:
- * @code
- * namespace my_ns
- * {
- * template <class T_functor>
- * struct my_adaptor : public sigc::adapts<T_functor>
- * {
- *   using result_type = typename sigc::functor_trait<T_functor>::result_type;
- *   //
- *   result_type
- *   operator()() const;
- *   //
- *   template <class T_arg1>
- *   decltype(auto)
- *   operator()(T_arg1 _A_arg1) const;
- *   //
- *   template <class T_arg1, class T_arg2>
- *   decltype(auto)
- *   operator()(T_arg1 _A_arg1, T_arg2 _A_arg2) const;
- *   //
- *   // Constructs a my_adaptor object that wraps the passed functor.
- *   // Initializes adapts<T_functor>::functor_, which is invoked from operator()().
- *   explicit my_adaptor(const T_functor& _A_functor)
- *     : sigc::adapts<T_functor>(_A_functor) {}
- * };
- * } // end namespace my_ns
- * //
- * // Specialization of sigc::visitor for my_adaptor.
- * namespace sigc
- * {
- * template <class T_functor>
- * struct visitor<my_ns::my_adaptor<T_functor> >
- * {
- *   template <class T_action>
- *   static void do_visit_each(const T_action& _A_action,
- *                             const my_ns::my_adaptor<T_functor>& _A_target)
- *   {
- *     sigc::visit_each(_A_action, _A_target.functor_);
- *   }
- * };
- * } // end namespace sigc
- * @endcode
- *
- * If you implement your own adaptor, you must also provide your specialization
- * of sigc::visitor<>::do_visit_each<>() that will forward the call to the functor(s)
- * your adapter is wrapping. Otherwise, pointers stored within the functor won't be
- * invalidated when a sigc::trackable object is destroyed and you can end up
- * executing callbacks on destroyed objects.
- *
- * Your specialization of sigc::visitor<> must be in namespace sigc.
- *
- * @ingroup adaptors
- */
-template <class T_functor>
-struct adapts : public adaptor_base
-{
-  using result_type = typename adaptor_trait<T_functor>::result_type;
-  using adaptor_type = typename adaptor_trait<T_functor>::adaptor_type;
-
-  /** Constructs an adaptor that wraps the passed functor.
-   * @param _A_functor Functor to invoke from operator()().
-   */
-  explicit adapts(const T_functor& _A_functor) : functor_(_A_functor) {}
-
-  /// Adaptor that is invoked from operator()().
-  mutable adaptor_type functor_;
-};
-
 } /* namespace sigc */
 #endif /* _SIGC_ADAPTORS_ADAPTOR_TRAIT_H_ */
diff --git a/sigc++/adaptors/adapts.h b/sigc++/adaptors/adapts.h
new file mode 100644
index 0000000..0003edc
--- /dev/null
+++ b/sigc++/adaptors/adapts.h
@@ -0,0 +1,92 @@
+#ifndef _SIGC_ADAPTORS_ADAPTS_H_
+#define _SIGC_ADAPTORS_ADAPTS_H_
+#include <sigc++config.h> //To get SIGC_TEMPLATE_KEYWORD_OPERATOR_OVERLOAD
+#include <sigc++/visit_each.h>
+#include <sigc++/functors/functor_trait.h>
+#include <sigc++/functors/ptr_fun.h>
+#include <sigc++/functors/mem_fun.h>
+#include <sigc++/adaptors/adaptor_trait.h>
+
+namespace sigc
+{
+
+// Doxygen (at least version 1.8.4) removes blank lines in a code block.
+// That's why there are empty comment lines in the following code block.
+/** Base type for adaptors.
+ * sigc::adapts wraps adaptors, functors, function pointers and class methods.
+ * It contains a single member functor which is always a sigc::adaptor_base.
+ * The adaptor_type alias defines the exact type that is used
+ * to store the adaptor, functor, function pointer or class method passed
+ * into the constructor. It differs from @a T_functor unless @a T_functor
+ * inherits from sigc::adaptor_base.
+ *
+ * @par Example of a simple adaptor:
+ * @code
+ * namespace my_ns
+ * {
+ * template <class T_functor>
+ * struct my_adaptor : public sigc::adapts<T_functor>
+ * {
+ *   using result_type = typename sigc::functor_trait<T_functor>::result_type;
+ *   //
+ *   result_type
+ *   operator()() const;
+ *   //
+ *   template <class T_arg1>
+ *   decltype(auto)
+ *   operator()(T_arg1 _A_arg1) const;
+ *   //
+ *   template <class T_arg1, class T_arg2>
+ *   decltype(auto)
+ *   operator()(T_arg1 _A_arg1, T_arg2 _A_arg2) const;
+ *   //
+ *   // Constructs a my_adaptor object that wraps the passed functor.
+ *   // Initializes adapts<T_functor>::functor_, which is invoked from operator()().
+ *   explicit my_adaptor(const T_functor& _A_functor)
+ *     : sigc::adapts<T_functor>(_A_functor) {}
+ * };
+ * } // end namespace my_ns
+ * //
+ * // Specialization of sigc::visitor for my_adaptor.
+ * namespace sigc
+ * {
+ * template <class T_functor>
+ * struct visitor<my_ns::my_adaptor<T_functor> >
+ * {
+ *   template <class T_action>
+ *   static void do_visit_each(const T_action& _A_action,
+ *                             const my_ns::my_adaptor<T_functor>& _A_target)
+ *   {
+ *     sigc::visit_each(_A_action, _A_target.functor_);
+ *   }
+ * };
+ * } // end namespace sigc
+ * @endcode
+ *
+ * If you implement your own adaptor, you must also provide your specialization
+ * of sigc::visitor<>::do_visit_each<>() that will forward the call to the functor(s)
+ * your adapter is wrapping. Otherwise, pointers stored within the functor won't be
+ * invalidated when a sigc::trackable object is destroyed and you can end up
+ * executing callbacks on destroyed objects.
+ *
+ * Your specialization of sigc::visitor<> must be in namespace sigc.
+ *
+ * @ingroup adaptors
+ */
+template <class T_functor>
+struct adapts : public adaptor_base
+{
+  using result_type = typename adaptor_trait<T_functor>::result_type;
+  using adaptor_type = typename adaptor_trait<T_functor>::adaptor_type;
+
+  /** Constructs an adaptor that wraps the passed functor.
+   * @param _A_functor Functor to invoke from operator()().
+   */
+  explicit adapts(const T_functor& _A_functor) : functor_(_A_functor) {}
+
+  /// Adaptor that is invoked from operator()().
+  mutable adaptor_type functor_;
+};
+
+} /* namespace sigc */
+#endif /* _SIGC_ADAPTORS_ADAPTS_H_ */
diff --git a/sigc++/adaptors/bind.h b/sigc++/adaptors/bind.h
index fcca3fd..9b2c98c 100644
--- a/sigc++/adaptors/bind.h
+++ b/sigc++/adaptors/bind.h
@@ -1,6 +1,6 @@
 #ifndef _SIGC_ADAPTORS_BIND_H_
 #define _SIGC_ADAPTORS_BIND_H_
-#include <sigc++/adaptors/adaptor_trait.h>
+#include <sigc++/adaptors/adapts.h>
 #include <sigc++/adaptors/bound_argument.h>
 #include <sigc++/adaptors/tuple_visitor_visit_each.h>
 #include <sigc++/tuple-utils/tuple_for_each.h>
diff --git a/sigc++/adaptors/bind_return.h b/sigc++/adaptors/bind_return.h
index 0f4f9b1..74c4738 100644
--- a/sigc++/adaptors/bind_return.h
+++ b/sigc++/adaptors/bind_return.h
@@ -1,6 +1,6 @@
 #ifndef _SIGC_ADAPTORS_BIND_RETURN_H_
 #define _SIGC_ADAPTORS_BIND_RETURN_H_
-#include <sigc++/adaptors/adaptor_trait.h>
+#include <sigc++/adaptors/adapts.h>
 #include <sigc++/adaptors/bound_argument.h>
 
 namespace sigc
diff --git a/sigc++/adaptors/compose.h b/sigc++/adaptors/compose.h
index 9a6c3e6..5c7aca9 100644
--- a/sigc++/adaptors/compose.h
+++ b/sigc++/adaptors/compose.h
@@ -1,6 +1,6 @@
 #ifndef _SIGC_ADAPTORS_COMPOSE_H_
 #define _SIGC_ADAPTORS_COMPOSE_H_
-#include <sigc++/adaptors/adaptor_trait.h>
+#include <sigc++/adaptors/adapts.h>
 
 namespace sigc
 {
diff --git a/sigc++/adaptors/exception_catch.h b/sigc++/adaptors/exception_catch.h
index dd2cb18..519e7cc 100644
--- a/sigc++/adaptors/exception_catch.h
+++ b/sigc++/adaptors/exception_catch.h
@@ -1,6 +1,6 @@
 #ifndef _SIGC_ADAPTORS_EXCEPTION_CATCH_H_
 #define _SIGC_ADAPTORS_EXCEPTION_CATCH_H_
-#include <sigc++/adaptors/adaptor_trait.h>
+#include <sigc++/adaptors/adapts.h>
 
 namespace sigc
 {
diff --git a/sigc++/adaptors/hide.h b/sigc++/adaptors/hide.h
index 0628c7c..2fe93b3 100644
--- a/sigc++/adaptors/hide.h
+++ b/sigc++/adaptors/hide.h
@@ -1,7 +1,7 @@
 #ifndef _SIGC_ADAPTORS_HIDE_H_
 #define _SIGC_ADAPTORS_HIDE_H_
 
-#include <sigc++/adaptors/adaptor_trait.h>
+#include <sigc++/adaptors/adapts.h>
 #include <sigc++/tuple-utils/tuple_end.h>
 #include <sigc++/tuple-utils/tuple_start.h>
 
diff --git a/sigc++/adaptors/retype.h b/sigc++/adaptors/retype.h
index 98c2c24..18b3edd 100644
--- a/sigc++/adaptors/retype.h
+++ b/sigc++/adaptors/retype.h
@@ -1,7 +1,7 @@
 #ifndef _SIGC_ADAPTORS_RETYPE_H_
 #define _SIGC_ADAPTORS_RETYPE_H_
 
-#include <sigc++/adaptors/adaptor_trait.h>
+#include <sigc++/adaptors/adapts.h>
 #include <sigc++/functors/ptr_fun.h>
 #include <sigc++/functors/mem_fun.h>
 #include <sigc++/functors/slot.h>
diff --git a/sigc++/adaptors/retype_return.h b/sigc++/adaptors/retype_return.h
index a261b43..5551d92 100644
--- a/sigc++/adaptors/retype_return.h
+++ b/sigc++/adaptors/retype_return.h
@@ -1,6 +1,6 @@
 #ifndef _SIGC_ADAPTORS_RETYPE_RETURN_H_
 #define _SIGC_ADAPTORS_RETYPE_RETURN_H_
-#include <sigc++/adaptors/adaptor_trait.h>
+#include <sigc++/adaptors/adapts.h>
 
 namespace sigc
 {
diff --git a/sigc++/adaptors/track_obj.h b/sigc++/adaptors/track_obj.h
index 6b138f4..a79ec2d 100644
--- a/sigc++/adaptors/track_obj.h
+++ b/sigc++/adaptors/track_obj.h
@@ -1,7 +1,7 @@
 #ifndef _SIGC_ADAPTORS_TRACK_OBJ_H_
 #define _SIGC_ADAPTORS_TRACK_OBJ_H_
 
-#include <sigc++/adaptors/adaptor_trait.h>
+#include <sigc++/adaptors/adapts.h>
 #include <sigc++/adaptors/tuple_visitor_visit_each.h>
 #include <sigc++/limit_reference.h>
 #include <sigc++/tuple-utils/tuple_for_each.h>
diff --git a/sigc++/filelist.am b/sigc++/filelist.am
index 134f0df..b53bef0 100644
--- a/sigc++/filelist.am
+++ b/sigc++/filelist.am
@@ -35,6 +35,7 @@ sigc_public_h =                               \
        tuple-utils/tuple_transform_each.h \
        type_traits.h                   \
        visit_each.h                    \
+       adaptors/adapts.h               \
        adaptors/adaptor_base.h \
        adaptors/adaptors.h             \
        adaptors/adaptor_trait.h                \
diff --git a/tests/test_visit_each.cc b/tests/test_visit_each.cc
index ec0a56e..c47fca1 100644
--- a/tests/test_visit_each.cc
+++ b/tests/test_visit_each.cc
@@ -22,6 +22,7 @@
 #include <sstream>
 #include <cstdlib>
 #include <sigc++/signal.h>
+#include <sigc++/adaptors/adapts.h>
 
 // SIGCTEST_CASE 1  Assume that class sigc::visitor has not been implemented.
 //                  Don't test with MyClass2, which is expected to fail in this case.


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