[libsigcplusplus] pointer_functor: Use the R(Args...) syntax.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsigcplusplus] pointer_functor: Use the R(Args...) syntax.
- Date: Wed, 16 Mar 2016 12:18:50 +0000 (UTC)
commit 1ae52bbc4f6b91051ae351b564d00f96502df5b1
Author: Murray Cumming <murrayc murrayc com>
Date: Wed Mar 16 13:10:57 2016 +0100
pointer_functor: Use the R(Args...) syntax.
sigc++/adaptors/retype.h | 19 +++++++++++++++++--
sigc++/functors/functor_trait.h | 2 +-
sigc++/functors/ptr_fun.h | 10 +++++++---
3 files changed, 25 insertions(+), 6 deletions(-)
---
diff --git a/sigc++/adaptors/retype.h b/sigc++/adaptors/retype.h
index 4c4e2fb..ba7a8b3 100644
--- a/sigc++/adaptors/retype.h
+++ b/sigc++/adaptors/retype.h
@@ -99,6 +99,21 @@ struct visitor<retype_functor<T_functor, T_type...> >
};
#endif // DOXYGEN_SHOULD_SKIP_THIS
+//This one takes, for instance, a mem_functor or bound_mem_functor:
+/** Creates an adaptor of type sigc::retype_functor which performs C-style casts on the parameters passed on
to the functor.
+ *
+ * @param _A_functor Functor that should be wrapped.
+ * @return Adaptor that executes @e _A_functor performing C-style casts on the paramters passed on.
+ *
+ * @ingroup retype
+ */
+template <template<class T_func, class... T_arg> class T_functor, class T_func, class... T_arg>
+inline decltype(auto)
+retype(const T_functor<T_func, T_arg...>& _A_functor)
+{ return retype_functor<T_functor<T_func, T_arg...>, T_arg...>
+ (_A_functor); }
+
+//This one takes, for instance, a pointer_functor or slot:
/** Creates an adaptor of type sigc::retype_functor which performs C-style casts on the parameters passed on
to the functor.
*
* @param _A_functor Functor that should be wrapped.
@@ -108,8 +123,8 @@ struct visitor<retype_functor<T_functor, T_type...> >
*/
template <template<class T_return, class... T_arg> class T_functor, class T_return, class... T_arg>
inline decltype(auto)
-retype(const T_functor<T_return, T_arg...>& _A_functor)
-{ return retype_functor<T_functor<T_return, T_arg...>, T_arg...>
+retype(const T_functor<T_return(T_arg...)>& _A_functor)
+{ return retype_functor<T_functor<T_return(T_arg...)>, T_arg...>
(_A_functor); }
} /* namespace sigc */
diff --git a/sigc++/functors/functor_trait.h b/sigc++/functors/functor_trait.h
index 94d80e7..9ac2977 100644
--- a/sigc++/functors/functor_trait.h
+++ b/sigc++/functors/functor_trait.h
@@ -198,7 +198,7 @@ template <class T_return, class... T_arg>
struct functor_trait<T_return (*)(T_arg...), false, false>
{
using result_type = T_return;
- using functor_type = pointer_functor<T_return, T_arg...>;
+ using functor_type = pointer_functor<T_return(T_arg...)>;
};
diff --git a/sigc++/functors/ptr_fun.h b/sigc++/functors/ptr_fun.h
index 527be3f..1daa1a9 100644
--- a/sigc++/functors/ptr_fun.h
+++ b/sigc++/functors/ptr_fun.h
@@ -49,7 +49,11 @@ namespace sigc {
* @ingroup ptr_fun
*/
template <class T_return, class... T_args>
-class pointer_functor : public functor_base
+class pointer_functor;
+
+template <class T_return, class... T_args>
+class pointer_functor<T_return(T_args...)>
+ : public functor_base
{
using function_type = T_return (*)(T_args...);
protected:
@@ -81,9 +85,9 @@ public:
* @ingroup ptr_fun
*/
template <class T_return, class... T_args>
-inline pointer_functor<T_return, T_args...>
+inline decltype(auto)
ptr_fun(T_return (*_A_func)(T_args...))
-{ return pointer_functor<T_return, T_args...>(_A_func); }
+{ return pointer_functor<T_return(T_args...)>(_A_func); }
} /* namespace sigc */
#endif /* _SIGC_FUNCTORS_PTR_FUN_H_ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]