[libsigcplusplus] Use mem_fun.h as a regular .h file.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsigcplusplus] Use mem_fun.h as a regular .h file.
- Date: Mon, 7 Mar 2016 10:25:36 +0000 (UTC)
commit d11c543e0008b7ac3a4656c89e768cc1925afd1d
Author: Murray Cumming <murrayc murrayc com>
Date: Mon Mar 7 11:23:04 2016 +0100
Use mem_fun.h as a regular .h file.
Instead of generating it from an .m4 file.
This still has some repetition, but it is not nearly as much as before,
and it is the last m4 file.
Having all the code in normal C++ source files makes it far easier for people
to contribute, to actually reduce this repetition.
sigc++/.gitignore | 1 -
sigc++/filelist.am | 14 +-
sigc++/functors/{macros/mem_fun.h.m4 => mem_fun.h} | 281 ++++++++++++++------
3 files changed, 197 insertions(+), 99 deletions(-)
---
diff --git a/sigc++/.gitignore b/sigc++/.gitignore
index 6069b32..e69de29 100644
--- a/sigc++/.gitignore
+++ b/sigc++/.gitignore
@@ -1 +0,0 @@
-/functors/mem_fun.h
diff --git a/sigc++/filelist.am b/sigc++/filelist.am
index 08fa0be..75ce246 100644
--- a/sigc++/filelist.am
+++ b/sigc++/filelist.am
@@ -15,19 +15,6 @@
## You should have received a copy of the GNU Lesser General Public License
## along with this library. If not, see <http://www.gnu.org/licenses/>.
-# Base (./)
-base_m4 = template.macros.m4
-
-# Functors (functors/)
-functors_m4 = mem_fun.h.m4
-functors_built_cc =
-functors_built_h = mem_fun.h
-
-# Combine all the above parts with right directories prefixed
-sigc_m4 = $(base_m4:%=macros/%) \
- $(functors_m4:%=functors/macros/%)
-sigc_built_cc = $(functors_built_cc:%=functors/%)
-sigc_built_h = $(functors_built_h:%=functors/%)
sigc_public_h = \
bind.h \
@@ -63,6 +50,7 @@ sigc_public_h = \
functors/functor_base.h \
functors/functor_trait.h \
functors/functors.h \
+ functors/mem_fun.h \
functors/ptr_fun.h \
functors/slot.h \
functors/slot_base.h
diff --git a/sigc++/functors/macros/mem_fun.h.m4 b/sigc++/functors/mem_fun.h
similarity index 52%
rename from sigc++/functors/macros/mem_fun.h.m4
rename to sigc++/functors/mem_fun.h
index 9056b91..25358dc 100644
--- a/sigc++/functors/macros/mem_fun.h.m4
+++ b/sigc++/functors/mem_fun.h
@@ -1,83 +1,13 @@
-dnl Copyright 2002, The libsigc++ Development Team
-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, write to the Free Software
-dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-dnl
-divert(-1)
-
-include(template.macros.m4)
-
-define([MEM_FUN],[dnl
-/** Creates a functor of type sigc::[$1]mem_functor which wraps a $3 method.
- * @param _A_func Pointer to method that should be wrapped.
- * @return Functor that executes _A_func on invokation.
- *
- * @ingroup mem_fun
- */
-template <class T_return, class T_obj, class... T_arg>
-inline decltype(auto)
-mem_fun(T_return (T_obj::*_A_func)(T_arg...) $3)
-{ return mem_functor<
- T_return (T_obj::*)(T_arg...) $3,
- T_arg...>(_A_func); }
-
-])
-define([BOUND_MEM_FUN],[dnl
-/** Creates a functor of type sigc::bound_[$1]mem_functor which encapsulates a method and an object instance.
- * @param _A_obj Pointer to object instance the functor should operate on.
- * @param _A_func Pointer to method that should be wrapped.
- * @return Functor that executes @e _A_func on invokation.
- *
- * @ingroup mem_fun
- */
-template <class T_return, class T_obj, class T_obj2, class... T_arg>
-inline decltype(auto)
-mem_fun(/*$2*/ T_obj* _A_obj, T_return (T_obj2::*_A_func)(T_arg...) $3)
-{
- return bound_mem_functor<
- T_return (T_obj::*)(T_arg...) $3,
- T_arg...>(*_A_obj, _A_func);
-}
-
-/** Creates a functor of type sigc::bound_[$1]mem_functor which encapsulates a method and an object instance.
- * @param _A_obj Reference to object instance the functor should operate on.
- * @param _A_func Pointer to method that should be wrapped.
- * @return Functor that executes @e _A_func on invokation.
- *
- * @ingroup mem_fun
- */
-template <class T_return, class T_obj, class T_obj2, class... T_arg>
-inline decltype(auto)
-mem_fun(/*$2*/ T_obj& _A_obj, T_return (T_obj2::*_A_func)(T_arg...) $3)
-{
- return bound_mem_functor<
- T_return (T_obj::*)(T_arg...) $3,
- T_arg...>(_A_obj, _A_func);
-}
-
-])
-
-divert(0)
+#ifndef _SIGC_FUNCTORS_MEM_FUN_H_
+#define _SIGC_FUNCTORS_MEM_FUN_H_
+#include <sigc++/type_traits.h>
+#include <sigc++/limit_reference.h>
+#include <sigc++/member_method_trait.h>
// implementation notes:
// - we do not use bind here, because it would introduce
// an extra copy and complicate the header include order if bind is
// to have automatic conversion for member pointers.
-_FIREWALL([FUNCTORS_MEM_FUN])
-#include <sigc++/type_traits.h>
-#include <sigc++/limit_reference.h>
-#include <sigc++/member_method_trait.h>
namespace sigc {
@@ -223,8 +153,8 @@ public:
#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.
- * The function overload for sigc::bound_[$1]mem_functor performs a functor
- * on the object instance stored in the sigc::bound_[$1]mem_functor object.
+ * The function overload for sigc::bound_$1mem_functor performs a functor
+ * on the object instance stored in the sigc::bound_$1mem_functor object.
*
* @ingroup mem_fun
*/
@@ -241,14 +171,195 @@ struct visitor<bound_mem_functor<T_func, T_arg...> >
#endif // DOXYGEN_SHOULD_SKIP_THIS
-MEM_FUN([],[],[])
-MEM_FUN([const_],[const],[const])
-MEM_FUN([volatile_],[],[volatile])
-MEM_FUN([const_volatile_],[const],[const volatile])
+/** Creates a functor of type sigc::mem_functor which wraps a method.
+ * @param _A_func Pointer to method that should be wrapped.
+ * @return Functor that executes _A_func on invokation.
+ *
+ * @ingroup mem_fun
+ */
+template <class T_return, class T_obj, class... T_arg>
+inline decltype(auto)
+mem_fun(T_return (T_obj::*_A_func)(T_arg...) )
+{ return mem_functor<
+ T_return (T_obj::*)(T_arg...) ,
+ T_arg...>(_A_func); }
+
+
+/** Creates a functor of type sigc::const_mem_functor which wraps a const method.
+ * @param _A_func Pointer to method that should be wrapped.
+ * @return Functor that executes _A_func on invokation.
+ *
+ * @ingroup mem_fun
+ */
+template <class T_return, class T_obj, class... T_arg>
+inline decltype(auto)
+mem_fun(T_return (T_obj::*_A_func)(T_arg...) const)
+{ return mem_functor<
+ T_return (T_obj::*)(T_arg...) const,
+ T_arg...>(_A_func); }
+
+
+/** Creates a functor of type sigc::volatile_mem_functor which wraps a volatile method.
+ * @param _A_func Pointer to method that should be wrapped.
+ * @return Functor that executes _A_func on invokation.
+ *
+ * @ingroup mem_fun
+ */
+template <class T_return, class T_obj, class... T_arg>
+inline decltype(auto)
+mem_fun(T_return (T_obj::*_A_func)(T_arg...) volatile)
+{ return mem_functor<
+ T_return (T_obj::*)(T_arg...) volatile,
+ T_arg...>(_A_func); }
+
+
+/** Creates a functor of type sigc::const_volatile_mem_functor which wraps a const volatile method.
+ * @param _A_func Pointer to method that should be wrapped.
+ * @return Functor that executes _A_func on invokation.
+ *
+ * @ingroup mem_fun
+ */
+template <class T_return, class T_obj, class... T_arg>
+inline decltype(auto)
+mem_fun(T_return (T_obj::*_A_func)(T_arg...) const volatile)
+{ return mem_functor<
+ T_return (T_obj::*)(T_arg...) const volatile,
+ T_arg...>(_A_func); }
+
+
+
+/** Creates a functor of type sigc::bound_mem_functor which encapsulates a method and an object instance.
+ * @param _A_obj Pointer to object instance the functor should operate on.
+ * @param _A_func Pointer to method that should be wrapped.
+ * @return Functor that executes @e _A_func on invokation.
+ *
+ * @ingroup mem_fun
+ */
+template <class T_return, class T_obj, class T_obj2, class... T_arg>
+inline decltype(auto)
+mem_fun(/**/ T_obj* _A_obj, T_return (T_obj2::*_A_func)(T_arg...) )
+{
+ return bound_mem_functor<
+ T_return (T_obj::*)(T_arg...) ,
+ T_arg...>(*_A_obj, _A_func);
+}
+
+/** Creates a functor of type sigc::bound_mem_functor which encapsulates a method and an object instance.
+ * @param _A_obj Reference to object instance the functor should operate on.
+ * @param _A_func Pointer to method that should be wrapped.
+ * @return Functor that executes @e _A_func on invokation.
+ *
+ * @ingroup mem_fun
+ */
+template <class T_return, class T_obj, class T_obj2, class... T_arg>
+inline decltype(auto)
+mem_fun(/**/ T_obj& _A_obj, T_return (T_obj2::*_A_func)(T_arg...) )
+{
+ return bound_mem_functor<
+ T_return (T_obj::*)(T_arg...) ,
+ T_arg...>(_A_obj, _A_func);
+}
+
+
+/** Creates a functor of type sigc::bound_const_mem_functor which encapsulates a method and an object
instance.
+ * @param _A_obj Pointer to object instance the functor should operate on.
+ * @param _A_func Pointer to method that should be wrapped.
+ * @return Functor that executes @e _A_func on invokation.
+ *
+ * @ingroup mem_fun
+ */
+template <class T_return, class T_obj, class T_obj2, class... T_arg>
+inline decltype(auto)
+mem_fun(/*const*/ T_obj* _A_obj, T_return (T_obj2::*_A_func)(T_arg...) const)
+{
+ return bound_mem_functor<
+ T_return (T_obj::*)(T_arg...) const,
+ T_arg...>(*_A_obj, _A_func);
+}
+
+/** Creates a functor of type sigc::bound_const_mem_functor which encapsulates a method and an object
instance.
+ * @param _A_obj Reference to object instance the functor should operate on.
+ * @param _A_func Pointer to method that should be wrapped.
+ * @return Functor that executes @e _A_func on invokation.
+ *
+ * @ingroup mem_fun
+ */
+template <class T_return, class T_obj, class T_obj2, class... T_arg>
+inline decltype(auto)
+mem_fun(/*const*/ T_obj& _A_obj, T_return (T_obj2::*_A_func)(T_arg...) const)
+{
+ return bound_mem_functor<
+ T_return (T_obj::*)(T_arg...) const,
+ T_arg...>(_A_obj, _A_func);
+}
+
+
+/** Creates a functor of type sigc::bound_volatile_mem_functor which encapsulates a method and an object
instance.
+ * @param _A_obj Pointer to object instance the functor should operate on.
+ * @param _A_func Pointer to method that should be wrapped.
+ * @return Functor that executes @e _A_func on invokation.
+ *
+ * @ingroup mem_fun
+ */
+template <class T_return, class T_obj, class T_obj2, class... T_arg>
+inline decltype(auto)
+mem_fun(/**/ T_obj* _A_obj, T_return (T_obj2::*_A_func)(T_arg...) volatile)
+{
+ return bound_mem_functor<
+ T_return (T_obj::*)(T_arg...) volatile,
+ T_arg...>(*_A_obj, _A_func);
+}
+
+/** Creates a functor of type sigc::bound_volatile_mem_functor which encapsulates a method and an object
instance.
+ * @param _A_obj Reference to object instance the functor should operate on.
+ * @param _A_func Pointer to method that should be wrapped.
+ * @return Functor that executes @e _A_func on invokation.
+ *
+ * @ingroup mem_fun
+ */
+template <class T_return, class T_obj, class T_obj2, class... T_arg>
+inline decltype(auto)
+mem_fun(/**/ T_obj& _A_obj, T_return (T_obj2::*_A_func)(T_arg...) volatile)
+{
+ return bound_mem_functor<
+ T_return (T_obj::*)(T_arg...) volatile,
+ T_arg...>(_A_obj, _A_func);
+}
+
+
+/** Creates a functor of type sigc::bound_const_volatile_mem_functor which encapsulates a method and an
object instance.
+ * @param _A_obj Pointer to object instance the functor should operate on.
+ * @param _A_func Pointer to method that should be wrapped.
+ * @return Functor that executes @e _A_func on invokation.
+ *
+ * @ingroup mem_fun
+ */
+template <class T_return, class T_obj, class T_obj2, class... T_arg>
+inline decltype(auto)
+mem_fun(/*const*/ T_obj* _A_obj, T_return (T_obj2::*_A_func)(T_arg...) const volatile)
+{
+ return bound_mem_functor<
+ T_return (T_obj::*)(T_arg...) const volatile,
+ T_arg...>(*_A_obj, _A_func);
+}
+
+/** Creates a functor of type sigc::bound_const_volatile_mem_functor which encapsulates a method and an
object instance.
+ * @param _A_obj Reference to object instance the functor should operate on.
+ * @param _A_func Pointer to method that should be wrapped.
+ * @return Functor that executes @e _A_func on invokation.
+ *
+ * @ingroup mem_fun
+ */
+template <class T_return, class T_obj, class T_obj2, class... T_arg>
+inline decltype(auto)
+mem_fun(/*const*/ T_obj& _A_obj, T_return (T_obj2::*_A_func)(T_arg...) const volatile)
+{
+ return bound_mem_functor<
+ T_return (T_obj::*)(T_arg...) const volatile,
+ T_arg...>(_A_obj, _A_func);
+}
+
-BOUND_MEM_FUN([],[],[])
-BOUND_MEM_FUN([const_],[const],[const])
-BOUND_MEM_FUN([volatile_],[],[volatile])
-BOUND_MEM_FUN([const_volatile_],[const],[const volatile])
} /* namespace sigc */
+#endif /* _SIGC_FUNCTORS_MEM_FUN_H_ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]