summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMurray Cumming <murrayc@murrayc.com>2016-01-15 23:51:06 +0100
committerMurray Cumming <murrayc@murrayc.com>2016-01-15 23:51:06 +0100
commitc0beabc7e02bd5a44860a394ece24e53be4301bc (patch)
treee5d81e2d5030578558bafe51b644058683125a6f
parentfd966a7c07687539ad8825cde3cbaf547fde6bda (diff)
downloadsigc++-c0beabc7e02bd5a44860a394ece24e53be4301bc.tar.gz
Functors: Do not derive from functor_base.
Because we don't need result_type any more.
-rw-r--r--sigc++/adaptors/adaptor_base.h5
-rw-r--r--sigc++/functors/functor_trait.h53
-rw-r--r--sigc++/functors/macros/mem_fun.h.m42
-rw-r--r--sigc++/functors/ptr_fun.h2
-rw-r--r--sigc++/functors/slot_base.h2
-rw-r--r--tests/test_bind.cc4
-rw-r--r--tests/test_compose.cc3
-rw-r--r--tests/test_exception_catch.cc6
-rw-r--r--tests/test_hide.cc6
-rw-r--r--tests/test_retype_return.cc4
-rw-r--r--tests/test_track_obj.cc4
11 files changed, 15 insertions, 76 deletions
diff --git a/sigc++/adaptors/adaptor_base.h b/sigc++/adaptors/adaptor_base.h
index 97b6f68..6cb71c7 100644
--- a/sigc++/adaptors/adaptor_base.h
+++ b/sigc++/adaptors/adaptor_base.h
@@ -9,9 +9,6 @@ namespace sigc {
* Functors which have all methods based on templates
* should publicly inherit from this hint.
*
- * adaptor_base inherits from the functor_base hint so
- * derived types should also have a result_type defined.
- *
* Adaptors don't inherit from this type directly. They use
* use sigc::adapts as a base type instead. sigc::adaptors
* wraps arbitrary functor types as well as function pointers
@@ -19,7 +16,7 @@ namespace sigc {
*
* @ingroup adaptors
*/
-struct adaptor_base : public functor_base {};
+struct adaptor_base {};
} /* namespace sigc */
#endif /* _SIGC_ADAPTORS_DEDUCE_RESULT_TYPE_H_ */
diff --git a/sigc++/functors/functor_trait.h b/sigc++/functors/functor_trait.h
index 54240be..8a54186 100644
--- a/sigc++/functors/functor_trait.h
+++ b/sigc++/functors/functor_trait.h
@@ -55,17 +55,8 @@ struct nil {};
* and you want them to be implicitly convertible into slots, libsigc++ must know
* the result type of your functors. There are different ways to achieve that.
*
- * - Derive your functors from sigc::functor_base and place
- * <tt>typedef T_return result_type;</tt> in the class definition.
* - Use the macro SIGC_FUNCTOR_TRAIT(T_functor,T_return) in namespace sigc.
* Multi-type functors are only partly supported.
- * - For functors not derived from sigc::functor_base, and not specified with
- * SIGC_FUNCTOR_TRAIT(), libsigc++ tries to deduce the result type with the
- * C++11 decltype() specifier. That attempt usually succeeds if the functor
- * has a single operator()(), but it fails if operator()() is overloaded.
- * - Use the macro #SIGC_FUNCTORS_HAVE_RESULT_TYPE, if you want libsigc++ to assume
- * that result_type is defined in all user-defined or third party functors,
- * whose result type can't be deduced in any other way.
*
* If all these ways to deduce the result type fail, void is assumed.
*
@@ -147,50 +138,6 @@ struct functor_trait<T_functor, false, true>
};
#endif // DOXYGEN_SHOULD_SKIP_THIS
-/** Helper macro, if you want to mix user-defined and third party functors with libsigc++.
- *
- * If you want to mix functors not derived from sigc::functor_base with libsigc++, and
- * these functors define @p result_type, use this macro inside namespace sigc like so:
- * @code
- * namespace sigc { SIGC_FUNCTORS_HAVE_RESULT_TYPE }
- * @endcode
- *
- * @ingroup sigcfunctors
- */
-#define SIGC_FUNCTORS_HAVE_RESULT_TYPE \
-template <class T_functor> \
-struct functor_trait<T_functor, false, false> \
-{ \
- typedef T_functor functor_type; \
-};
-
-/** Helper macro, if you want to mix user-defined and third party functors with libsigc++.
- *
- * If you want to mix functors not derived from sigc::functor_base with libsigc++, and
- * these functors don't define @p result_type, use this macro inside namespace sigc
- * to expose the return type of the functors like so:
- * @code
- * namespace sigc {
- * SIGC_FUNCTOR_TRAIT(first_functor_type, return_type_of_first_functor_type)
- * SIGC_FUNCTOR_TRAIT(second_functor_type, return_type_of_second_functor_type)
- * ...
- * }
- * @endcode
- *
- * @ingroup sigcfunctors
- */
-#define SIGC_FUNCTOR_TRAIT(T_functor,T_return) \
-template <> \
-struct functor_trait<T_functor, false, false> \
-{ \
- typedef T_functor functor_type; \
-}; \
-template <> \
-struct functor_trait<T_functor, false, true> \
-{ \
- typedef T_functor functor_type; \
-};
-
#ifndef DOXYGEN_SHOULD_SKIP_THIS
// detect the the functor version of non-functor types.
diff --git a/sigc++/functors/macros/mem_fun.h.m4 b/sigc++/functors/macros/mem_fun.h.m4
index ca9051f..551fd22 100644
--- a/sigc++/functors/macros/mem_fun.h.m4
+++ b/sigc++/functors/macros/mem_fun.h.m4
@@ -30,7 +30,7 @@ define([MEMBER_FUNCTOR],[dnl
* @ingroup mem_fun
*/
template <class T_return, class T_obj, class... T_arg>
-class [$1]mem_functor : public functor_base
+class [$1]mem_functor
{
public:
typedef T_return (T_obj::*function_type)(T_arg...) $3;
diff --git a/sigc++/functors/ptr_fun.h b/sigc++/functors/ptr_fun.h
index 41eb85f..63f4b43 100644
--- a/sigc++/functors/ptr_fun.h
+++ b/sigc++/functors/ptr_fun.h
@@ -50,7 +50,7 @@ namespace sigc {
* @ingroup ptr_fun
*/
template <class T_return, class... T_args>
-class pointer_functor : public functor_base
+class pointer_functor
{
using function_type = T_return (*)(T_args...);
protected:
diff --git a/sigc++/functors/slot_base.h b/sigc++/functors/slot_base.h
index 8ecd086..9b9a5d4 100644
--- a/sigc++/functors/slot_base.h
+++ b/sigc++/functors/slot_base.h
@@ -240,7 +240,7 @@ struct SIGC_API slot_do_unbind
*
* @ingroup slot
*/
-class SIGC_API slot_base : public functor_base
+class SIGC_API slot_base
{
typedef internal::slot_rep rep_type;
diff --git a/tests/test_bind.cc b/tests/test_bind.cc
index 3ab7cf6..57486bd 100644
--- a/tests/test_bind.cc
+++ b/tests/test_bind.cc
@@ -15,7 +15,7 @@ namespace
{
std::ostringstream result_stream;
-struct foo : public sigc::functor_base
+struct foo
{
// choose a type that can hold all return values
typedef int result_type;
@@ -39,7 +39,7 @@ struct foo : public sigc::functor_base
}
};
-struct foo_void : public sigc::functor_base
+struct foo_void
{
typedef void result_type;
diff --git a/tests/test_compose.cc b/tests/test_compose.cc
index a626ba6..132f413 100644
--- a/tests/test_compose.cc
+++ b/tests/test_compose.cc
@@ -8,9 +8,6 @@
#include <sstream>
#include <cstdlib>
-// assume existance of T_functor::result_type for unknown functor types:
-namespace sigc { SIGC_FUNCTORS_HAVE_RESULT_TYPE }
-
namespace
{
std::ostringstream result_stream;
diff --git a/tests/test_exception_catch.cc b/tests/test_exception_catch.cc
index 6ae7e51..8e4ac28 100644
--- a/tests/test_exception_catch.cc
+++ b/tests/test_exception_catch.cc
@@ -13,7 +13,7 @@ namespace
{
std::ostringstream result_stream;
-struct f : public sigc::functor_base
+struct f
{
typedef int result_type;
@@ -24,7 +24,7 @@ struct f : public sigc::functor_base
}
};
-struct g : public sigc::functor_base
+struct g
{
typedef int result_type;
@@ -35,7 +35,7 @@ struct g : public sigc::functor_base
}
};
-struct g_void : public sigc::functor_base
+struct g_void
{
typedef void result_type;
diff --git a/tests/test_hide.cc b/tests/test_hide.cc
index c1cdad2..1f53d50 100644
--- a/tests/test_hide.cc
+++ b/tests/test_hide.cc
@@ -12,7 +12,7 @@ namespace
{
std::ostringstream result_stream;
-struct foo : public sigc::functor_base
+struct foo
{
// choose a type that can hold all return values
typedef int result_type;
@@ -30,7 +30,7 @@ struct foo : public sigc::functor_base
}
};
-struct foo_void : public sigc::functor_base
+struct foo_void
{
typedef void result_type;
@@ -42,8 +42,6 @@ struct foo_void : public sigc::functor_base
} // end anonymous namespace
-namespace sigc { SIGC_FUNCTOR_TRAIT(foo,bool) }
-
int main(int argc, char* argv[])
{
auto util = TestUtilities::get_instance();
diff --git a/tests/test_retype_return.cc b/tests/test_retype_return.cc
index 9026e32..259d71e 100644
--- a/tests/test_retype_return.cc
+++ b/tests/test_retype_return.cc
@@ -13,7 +13,7 @@ namespace
{
std::ostringstream result_stream;
-struct foo : public sigc::functor_base
+struct foo
{
typedef float result_type;
@@ -30,7 +30,7 @@ struct foo : public sigc::functor_base
}
};
-struct bar : public sigc::trackable, public sigc::functor_base
+struct bar : public sigc::trackable
{
typedef int result_type;
diff --git a/tests/test_track_obj.cc b/tests/test_track_obj.cc
index 635be0c..bd39a67 100644
--- a/tests/test_track_obj.cc
+++ b/tests/test_track_obj.cc
@@ -59,7 +59,7 @@ struct bar_group4 : public sigc::trackable
{
};
-class Functor1 : public sigc::functor_base
+class Functor1
{
public:
typedef std::string result_type;
@@ -76,7 +76,7 @@ private:
const bar_group4& bar_;
};
-class Functor2 : public sigc::functor_base
+class Functor2
{
public:
typedef std::string result_type;