[libsigc++2] Replace visit_each() overloads by struct visitor<>
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsigc++2] Replace visit_each() overloads by struct visitor<>
- Date: Sun, 27 Jul 2014 14:00:30 +0000 (UTC)
commit 81c778422768f14eb9ed18645a0a4352dd37c2cb
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date: Sun Jul 27 15:38:30 2014 +0200
Replace visit_each() overloads by struct visitor<>
Note: This patch breaks API for some users, but it does not break ABI.
Only users who have added their own visit_each() overloads are affected by
the API break. Their programs will still compile, but there will be run-time
errors, if they rely on auto-disconnection of slots.
Updated instructions for users who implement their own adaptors are found in
the description of sigc::adapts<>.
* sigc++/adaptors/bound_argument.h:
* sigc++/adaptors/macros/adaptor_trait.h.m4:
* sigc++/adaptors/macros/bind.h.m4:
* sigc++/adaptors/macros/bind_return.h.m4:
* sigc++/adaptors/macros/compose.h.m4:
* sigc++/adaptors/macros/exception_catch.h.m4:
* sigc++/adaptors/macros/hide.h.m4:
* sigc++/adaptors/macros/retype.h.m4:
* sigc++/adaptors/macros/retype_return.h.m4:
* sigc++/adaptors/macros/track_obj.h.m4:
* sigc++/adaptors/lambda/macros/base.h.m4:
* sigc++/adaptors/lambda/macros/group.h.m4:
* sigc++/adaptors/lambda/macros/operator.h.m4:
* sigc++/functors/macros/mem_fun.h.m4:
* sigc++/macros/limit_reference.h.m4:
* sigc++/visit_each.h: Replace overloads of visit_each<>() by
specializations of struct visitor<> with a specialized member function
do_visit_each<>(). Qualify all calls to visit_each() with sigc:: to avoid
argument-dependent lookup.
* sigc++/functors/macros/slot.h.m4: Qualify the calls to visit_each_type()
with sigc:: to avoid argument-dependent lookup.
* tests/test_functor_trait.cc: Fix the expected result now when the test
really works.
Thanks to Ryan Beasley <rbeasley vmware com>, bug #724496.
sigc++/adaptors/bound_argument.h | 25 ++++---
sigc++/adaptors/lambda/macros/base.h.m4 | 87 ++++++++++++----------
sigc++/adaptors/lambda/macros/group.h.m4 | 50 +++++++------
sigc++/adaptors/lambda/macros/operator.h.m4 | 82 ++++++++++++---------
sigc++/adaptors/macros/adaptor_trait.h.m4 | 107 +++++++++++++++------------
sigc++/adaptors/macros/bind.h.m4 | 76 +++++++++++---------
sigc++/adaptors/macros/bind_return.h.m4 | 48 +++++++------
sigc++/adaptors/macros/compose.h.m4 | 86 ++++++++++------------
sigc++/adaptors/macros/exception_catch.h.m4 | 62 ++++++++-------
sigc++/adaptors/macros/hide.h.m4 | 50 +++++++------
sigc++/adaptors/macros/retype.h.m4 | 48 +++++++------
sigc++/adaptors/macros/retype_return.h.m4 | 48 +++++++------
sigc++/adaptors/macros/track_obj.h.m4 | 20 +++--
sigc++/functors/macros/mem_fun.h.m4 | 48 +++++++------
sigc++/functors/macros/slot.h.m4 | 40 +++++-----
sigc++/macros/limit_reference.h.m4 | 52 +++++++------
sigc++/visit_each.h | 80 ++++++++++++++------
tests/test_functor_trait.cc | 9 +-
18 files changed, 559 insertions(+), 459 deletions(-)
---
diff --git a/sigc++/adaptors/bound_argument.h b/sigc++/adaptors/bound_argument.h
index bad1fdb..0579682 100644
--- a/sigc++/adaptors/bound_argument.h
+++ b/sigc++/adaptors/bound_argument.h
@@ -36,10 +36,10 @@ namespace sigc {
*
* Likewise, If Foo is a wrapped const reference to a class Bar (const_reference_wrapper<Bar>)
* then this object is implemented on top of a const_limit_reference.
- *
+ *
* If Foo is something else (such as an argument that is bound by value) bound_argument just
* stores a cop of that value, and both invoke() and visit() simply return it.
- *
+ *
* This object is used by the bind_functor<> and bind_return_functor<> objects,
* depending on whether the argument is bound as a parameter or as a return value.
*
@@ -143,21 +143,24 @@ private:
};
#ifndef DOXYGEN_SHOULD_SKIP_THIS
-/** Implementation of visit_each() specialized for the bound_argument class.
+/** Implementation of visitor<>::do_visit_each<>() specialized for the bound_argument class.
* Call visit_each() on the entity returned by the bound_argument's visit()
* method.
- * @e T_action The type of functor to invoke.
- * @e T_type The type of bound_argument.
+ * @tparam T_type The type of bound_argument.
+ * @tparam T_action The type of functor to invoke.
* @param _A_action The functor to invoke.
* @param _A_argument The visited instance.
*/
-template <class T_action, class T_type>
-void
-visit_each(const T_action& _A_action,
- const bound_argument<T_type>& _A_argument)
+template <class T_type>
+struct visitor<bound_argument<T_type> >
{
- visit_each(_A_action, _A_argument.visit());
-}
+ template <class T_action>
+ static void do_visit_each(const T_action& _A_action,
+ const bound_argument<T_type>& _A_argument)
+ {
+ sigc::visit_each(_A_action, _A_argument.visit());
+ }
+};
#endif // DOXYGEN_SHOULD_SKIP_THIS
} /* namespace sigc */
diff --git a/sigc++/adaptors/lambda/macros/base.h.m4 b/sigc++/adaptors/lambda/macros/base.h.m4
index 274aa65..efc9476 100644
--- a/sigc++/adaptors/lambda/macros/base.h.m4
+++ b/sigc++/adaptors/lambda/macros/base.h.m4
@@ -1,18 +1,18 @@
-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 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)
@@ -20,9 +20,9 @@ include(template.macros.m4)
define([LAMBDA_DO],[dnl
template <LOOP(class T_arg%1, $1)>
typename deduce_result_type<LOOP(T_arg%1,$1)>::type
- operator ()(LOOP(T_arg%1 _A_%1, $1)) const
+ operator ()(LOOP(T_arg%1 _A_%1, $1)) const
{ return value_.SIGC_WORKAROUND_OPERATOR_PARENTHESES<LOOP(_P_(T_arg%1), $1)>
- (LOOP(_A_%1, $1));
+ (LOOP(_A_%1, $1));
}
#ifndef SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD
@@ -30,14 +30,14 @@ define([LAMBDA_DO],[dnl
typename deduce_result_type<LOOP(T_arg%1,$1)>::type
sun_forte_workaround(LOOP(T_arg%1 _A_%1, $1)) const
{ return value_.SIGC_WORKAROUND_OPERATOR_PARENTHESES<LOOP(_P_(T_arg%1), $1)>
- (LOOP(_A_%1, $1));
+ (LOOP(_A_%1, $1));
}
#endif //SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD
])dnl
define([LAMBDA_DO_VALUE],[dnl
template <LOOP(class T_arg%1, $1)>
- result_type operator ()(LOOP(T_arg%1, $1)) const
+ result_type operator ()(LOOP(T_arg%1, $1)) const
{ return value_; }
#ifndef SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD
@@ -181,14 +181,17 @@ typename lambda_core<T_type, false>::result_type lambda_core<T_type, false>::ope
} /* namespace internal */
-
-//template specialization of visit_each<>(action, functor):
-template <class T_action, class T_functor, bool I_islambda>
-void visit_each(const T_action& _A_action,
- const internal::lambda_core<T_functor, I_islambda>& _A_target)
+//template specialization of visitor<>::do_visit_each<>(action, functor):
+template <class T_functor, bool I_islambda>
+struct visitor<internal::lambda_core<T_functor, I_islambda> >
{
- visit_each(_A_action, _A_target.value_);
-}
+ template <class T_action>
+ static void do_visit_each(const T_action& _A_action,
+ const internal::lambda_core<T_functor, I_islambda>& _A_target)
+ {
+ sigc::visit_each(_A_action, _A_target.value_);
+ }
+};
// forward declarations for lambda operators other<subscript> and other<assign>
template <class T_type>
@@ -255,7 +258,7 @@ struct lambda : public internal::lambda_core<T_type>
{}
lambda(typename type_trait<T_type>::take v)
- : internal::lambda_core<T_type>(v)
+ : internal::lambda_core<T_type>(v)
{}
// operators for other<subscript>
@@ -274,13 +277,17 @@ struct lambda : public internal::lambda_core<T_type>
};
#ifndef DOXYGEN_SHOULD_SKIP_THIS
-//template specialization of visit_each<>(action, functor):
-template <class T_action, class T_type>
-void visit_each(const T_action& _A_action,
- const lambda<T_type>& _A_target)
+//template specialization of visitor<>::do_visit_each<>(action, functor):
+template <class T_type>
+struct visitor<lambda<T_type> >
{
- visit_each(_A_action, _A_target.value_);
-}
+ template <class T_action>
+ static void do_visit_each(const T_action& _A_action,
+ const lambda<T_type>& _A_target)
+ {
+ sigc::visit_each(_A_action, _A_target.value_);
+ }
+};
#endif // DOXYGEN_SHOULD_SKIP_THIS
dnl /* With the Sun FORTE and the Compaq C++ compiler,
@@ -291,34 +298,34 @@ dnl * but neither with the Sun FORTE nor with the Compaq C++ compiler
dnl * (for the gcc the work-around is not needed, anyway):
dnl */
dnl namespace internal {
-dnl
+dnl
dnl template <class T_type>
dnl struct convert_array
dnl { typedef T_type& type; };
-dnl
+dnl
dnl template <class T_type, int N>
dnl struct convert_array<T_type[[N]]>
dnl { typedef T_type* type; };
-dnl
+dnl
dnl } /* namespace internal */
-dnl
+dnl
dnl /// Converts a constant variable into a lambda object.
dnl template <class T_type>
dnl lambda<T_type> constant(const T_type& v)
dnl { return lambda<T_type>(v); }
-dnl
+dnl
dnl /// Converts a reference into a lambda object.
dnl template <class T_type>
dnl lambda<typename internal::convert_array<T_type>::type> var(T_type& v)
dnl { return lambda<typename internal::convert_array<T_type>::type>(v); }
-dnl
+dnl
dnl /// Converts a constant reference into a lambda object.
dnl template <class T_type>
dnl lambda<typename internal::convert_array<const T_type>::type> var(const T_type& v)
dnl { return lambda<typename internal::convert_array<const T_type>::type>(v); }
/** Converts a reference into a lambda object.
- * sigc::var creates a 0-ary functor, returning the value of a referenced variable.
+ * sigc::var creates a 0-ary functor, returning the value of a referenced variable.
*
* @par Example:
* @code
diff --git a/sigc++/adaptors/lambda/macros/group.h.m4 b/sigc++/adaptors/lambda/macros/group.h.m4
index 353d6e6..c76d072 100644
--- a/sigc++/adaptors/lambda/macros/group.h.m4
+++ b/sigc++/adaptors/lambda/macros/group.h.m4
@@ -1,18 +1,18 @@
-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 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)
@@ -106,15 +106,19 @@ typename lambda_group$1<T_functor, LOOP(T_type%1, $1)>::result_type
lambda_group$1<T_functor, LOOP(T_type%1, $1)>::operator ()() const
{ return func_(LOOP(value%1_(), $1)); }
-//template specialization of visit_each<>(action, functor):
-template <class T_action, class T_functor, LOOP(class T_type%1, $1)>
-void visit_each(const T_action& _A_action,
- const lambda_group$1<T_functor, LOOP(T_type%1, $1)>& _A_target)
-{dnl
+//template specialization of visitor<>::do_visit_each<>(action, functor):
+template <class T_functor, LOOP(class T_type%1, $1)>
+struct visitor<lambda_group$1<T_functor, LOOP(T_type%1, $1)> >
+{
+ template <class T_action>
+ static void do_visit_each(const T_action& _A_action,
+ const lambda_group$1<T_functor, LOOP(T_type%1, $1)>& _A_target)
+ {dnl
FOR(1, $1,[
- visit_each(_A_action, _A_target.value%1_);])
- visit_each(_A_action, _A_target.func_);
-}
+ sigc::visit_each(_A_action, _A_target.value%1_);])
+ sigc::visit_each(_A_action, _A_target.func_);
+ }
+};
#endif // DOXYGEN_SHOULD_SKIP_THIS
])
diff --git a/sigc++/adaptors/lambda/macros/operator.h.m4 b/sigc++/adaptors/lambda/macros/operator.h.m4
index 3979662..ee64e23 100644
--- a/sigc++/adaptors/lambda/macros/operator.h.m4
+++ b/sigc++/adaptors/lambda/macros/operator.h.m4
@@ -1,23 +1,23 @@
-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 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)
-dnl
+dnl
dnl Macros to make operators
define([LAMBDA_OPERATOR_DO],[dnl
template <LOOP(class T_arg%1, $1)>
@@ -450,14 +450,18 @@ lambda_operator<T_action, T_type1, T_type2>::operator ()() const
typename arg2_type::result_type>
(arg1_(), arg2_()); }
-//template specialization of visit_each<>(action, functor):
-template <class T_action, class T_lambda_action, class T_arg1, class T_arg2>
-void visit_each(const T_action& _A_action,
- const lambda_operator<T_lambda_action, T_arg1, T_arg2>& _A_target)
+//template specialization of visitor<>::do_visit_each<>(action, functor):
+template <class T_lambda_action, class T_arg1, class T_arg2>
+struct visitor<lambda_operator<T_lambda_action, T_arg1, T_arg2> >
{
- visit_each(_A_action, _A_target.arg1_);
- visit_each(_A_action, _A_target.arg2_);
-}
+ template <class T_action>
+ static void do_visit_each(const T_action& _A_action,
+ const lambda_operator<T_lambda_action, T_arg1, T_arg2>& _A_target)
+ {
+ sigc::visit_each(_A_action, _A_target.arg1_);
+ sigc::visit_each(_A_action, _A_target.arg2_);
+ }
+};
template <class T_action, class T_type>
@@ -492,13 +496,17 @@ lambda_operator_unary<T_action, T_type>::operator ()() const
typename arg_type::result_type>
(arg_()); }
-//template specialization of visit_each<>(action, functor):
-template <class T_action, class T_lambda_action, class T_arg>
-void visit_each(const T_action& _A_action,
- const lambda_operator_unary<T_lambda_action, T_arg>& _A_target)
+//template specialization of visitor<>::do_visit_each<>(action, functor):
+template <class T_lambda_action, class T_arg>
+struct visitor<lambda_operator_unary<T_lambda_action, T_arg> >
{
- visit_each(_A_action, _A_target.arg_);
-}
+ template <class T_action>
+ static void do_visit_each(const T_action& _A_action,
+ const lambda_operator_unary<T_lambda_action, T_arg>& _A_target)
+ {
+ sigc::visit_each(_A_action, _A_target.arg_);
+ }
+};
template <class T_action, class T_type, class T_arg>
@@ -533,13 +541,17 @@ lambda_operator_convert<T_action, T_type, T_arg>::operator ()() const
typename arg_type::result_type>
(arg_()); }
-//template specialization of visit_each<>(action, functor):
-template <class T_action, class T_lambda_action, class T_type, class T_arg>
-void visit_each(const T_action& _A_action,
- const lambda_operator_convert<T_lambda_action, T_type, T_arg>& _A_target)
+//template specialization of visitor<>::do_visit_each<>(action, functor):
+template <class T_lambda_action, class T_type, class T_arg>
+struct visitor<lambda_operator_convert<T_lambda_action, T_type, T_arg> >
{
- visit_each(_A_action, _A_target.arg_);
-}
+ template <class T_action>
+ static void do_visit_each(const T_action& _A_action,
+ const lambda_operator_convert<T_lambda_action, T_type, T_arg>& _A_target)
+ {
+ sigc::visit_each(_A_action, _A_target.arg_);
+ }
+};
undivert(2)dnl
diff --git a/sigc++/adaptors/macros/adaptor_trait.h.m4 b/sigc++/adaptors/macros/adaptor_trait.h.m4
index 76a936b..cb95f6b 100644
--- a/sigc++/adaptors/macros/adaptor_trait.h.m4
+++ b/sigc++/adaptors/macros/adaptor_trait.h.m4
@@ -1,29 +1,29 @@
-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 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)
dnl
-dnl The idea here is simple. To prevent the need to
+dnl The idea here is simple. To prevent the need to
dnl specializing every adaptor for every type of functor
dnl and worse non-functors like function pointers, we
dnl will make an adaptor trait which can take ordinary
-dnl functors and make them adaptor functors for which
-dnl we will of course be able to avoid excess copies.
+dnl functors and make them adaptor functors for which
+dnl we will of course be able to avoid excess copies.
dnl (in theory)
dnl
dnl this all depends on partial specialization to allow
@@ -66,7 +66,7 @@ FOR(1, $1,[
return functor_(LOOP(_A_arg%1, $1));
}
#endif
-
+
])dnl
])
@@ -148,7 +148,7 @@ struct adaptor_functor : public adaptor_base
result_type sun_forte_workaround() const
{ return operator(); }
#endif
-
+
FOR(0,CALL_SIZE,[[ADAPTOR_DO(%1)]])dnl
/// Constructs an invalid functor.
adaptor_functor()
@@ -180,21 +180,23 @@ adaptor_functor<T_functor>::operator()() const
{ return functor_(); }
#ifndef DOXYGEN_SHOULD_SKIP_THIS
-//template specialization of visit_each<>(action, functor):
+//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::adaptor_functor performs a functor
* on the functor stored in the sigc::adaptor_functor object.
*
* @ingroup adaptors
*/
-template <class T_action, class T_functor>
-void visit_each(const T_action& _A_action,
- const adaptor_functor<T_functor>& _A_target)
+template <class T_functor>
+struct visitor<adaptor_functor<T_functor> >
{
- //The extra sigc:: prefix avoids ambiguity in some strange
- //situations.
- sigc::visit_each(_A_action, _A_target.functor_);
-}
+ template <class T_action>
+ static void do_visit_each(const T_action& _A_action,
+ const adaptor_functor<T_functor>& _A_target)
+ {
+ sigc::visit_each(_A_action, _A_target.functor_);
+ }
+};
#endif // DOXYGEN_SHOULD_SKIP_THIS
/** Trait that specifies what is the adaptor version of a functor type.
@@ -216,7 +218,7 @@ template <class T_functor, bool I_isadaptor = is_base_and_derived<adaptor_base,
* This template specialization is used for types that inherit from adaptor_base.
* adaptor_type is equal to @p T_functor in this case.
*/
-template <class T_functor>
+template <class T_functor>
struct adaptor_trait<T_functor, true>
{
typedef typename T_functor::result_type result_type;
@@ -238,17 +240,20 @@ struct adaptor_trait<T_functor, false>
typedef adaptor_functor<functor_type> adaptor_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.
- * adapts wraps adaptors, functors, function pointers and class methods.
+ * sigc::adapts wraps adaptors, functors, function pointers and class methods.
* It contains a single member functor which is always a sigc::adaptor_base.
* The typedef adaptor_type defines the exact type that is used
* to store the adaptor, functor, function pointer or class method passed
- * into the constructor. It differs from @e T_functor unless @e T_functor
+ * 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>
* {
@@ -256,40 +261,48 @@ struct adaptor_trait<T_functor, false>
* struct deduce_result_type
* { typedef typename sigc::deduce_result_type<T_functor, T_arg1, T_arg2>::type type; };
* typedef typename sigc::functor_trait<T_functor>::result_type result_type;
- *
+ * //
* result_type
* operator()() const;
- *
+ * //
* template <class T_arg1>
* typename deduce_result_type<T_arg1>::type
* operator()(T_arg1 _A_arg1) const;
- *
+ * //
* template <class T_arg1, class T_arg2>
* typename deduce_result_type<T_arg1, T_arg2>::type
- * operator()(T_arg1 _A_arg1, class T_arg2) const;
- *
+ * 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) {}
* };
- *
- * template <class T_action, class T_functor>
- * void visit_each(const T_action& _A_action,
- * const my_adaptor<T_functor>& _A_target)
+ * } // 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> >
* {
- * visit_each(_A_action, _A_target.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 visit_each<>() that will forward the call to the functor(s) your
- * adapter is wrapping. Otherwise, pointers stored within the functor won't be
+ * 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 adaptor and your specialization of visit_each<>() must be in the same
- * namespace.
+ * Your specialization of sigc::visitor<> must be in namespace sigc.
*
* @ingroup adaptors
*/
diff --git a/sigc++/adaptors/macros/bind.h.m4 b/sigc++/adaptors/macros/bind.h.m4
index 84fab5b..7d413d5 100644
--- a/sigc++/adaptors/macros/bind.h.m4
+++ b/sigc++/adaptors/macros/bind.h.m4
@@ -1,18 +1,18 @@
-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 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)
@@ -49,7 +49,7 @@ FOR(1, eval($2-1),[
(LIST(LOOP(_A_arg%1,eval($1-1)), bound_.invoke(), FOR($1,eval($2-1),[_A_arg%1,])));
}
#endif
-
+
])dnl
])
define([BIND_OPERATOR_COUNT],[dnl
@@ -74,7 +74,7 @@ FOR(1, eval($2-1),[
(LIST(LOOP(_A_arg%1,eval($2-1)), LOOP(bound%1_.invoke(), $1)));
}
#endif
-
+
])
define([BIND_FUNCTOR_LOCATION],[dnl
ifelse($1,1,[#ifndef DOXYGEN_SHOULD_SKIP_THIS
@@ -179,22 +179,26 @@ FOR(1,$1,[
ifelse($1,1,[#ifndef DOXYGEN_SHOULD_SKIP_THIS
],)dnl Include only the first template specialization of bind_functor and no
-dnl template specialization of visit_each in the documentation. ($1 = 1..CALL_SIZE)
-//template specialization of visit_each<>(action, functor):
+dnl template specialization of visitor in the documentation. ($1 = 1..CALL_SIZE)
+//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::bind_functor performs a functor on the
* functor and on the object instances stored in the sigc::bind_functor object.
*
* @ingroup bind
*/
-template <class T_action, class T_functor, LOOP(class T_type%1, $1)>
-void visit_each(const T_action& _A_action,
- const bind_functor<-1, T_functor, LOOP(T_type%1, $1)>& _A_target)
+template <class T_functor, LOOP(class T_type%1, $1)>
+struct visitor<bind_functor<-1, T_functor, LOOP(T_type%1, $1)> >
{
- visit_each(_A_action, _A_target.functor_);dnl
+ template <typename T_action>
+ static void do_visit_each(const T_action& _A_action,
+ const bind_functor<-1, T_functor, LOOP(T_type%1, $1)>& _A_target)
+ {
+ sigc::visit_each(_A_action, _A_target.functor_);dnl
FOR(1,$1,[
- visit_each(_A_action, _A_target.bound%1_);])
-}
+ sigc::visit_each(_A_action, _A_target.bound%1_);])
+ }
+};
ifelse($1,CALL_SIZE,[#endif // DOXYGEN_SHOULD_SKIP_THIS
],)dnl
@@ -231,7 +235,7 @@ _FIREWALL([ADAPTORS_BIND])
#include <sigc++/adaptors/adaptor_trait.h>
#include <sigc++/adaptors/bound_argument.h>
-namespace sigc {
+namespace sigc {
#ifndef DOXYGEN_SHOULD_SKIP_THIS
@@ -362,20 +366,24 @@ struct bind_functor {};
FOR(0,eval(CALL_SIZE-1),[[BIND_FUNCTOR_LOCATION(%1)]])dnl
#ifndef DOXYGEN_SHOULD_SKIP_THIS
-//template specialization of visit_each<>(action, functor):
+//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::bind_functor performs a functor on the
* functor and on the object instances stored in the sigc::bind_functor object.
*
* @ingroup bind
*/
-template <class T_action, int T_loc, class T_functor, class T_bound>
-void visit_each(const T_action& _A_action,
- const bind_functor<T_loc, T_functor, T_bound>& _A_target)
+template <int T_loc, class T_functor, class T_bound>
+struct visitor<bind_functor<T_loc, T_functor, T_bound> >
{
- visit_each(_A_action, _A_target.functor_);
- visit_each(_A_action, _A_target.bound_);
-}
+ template <class T_action>
+ static void do_visit_each(const T_action& _A_action,
+ const bind_functor<T_loc, T_functor, T_bound>& _A_target)
+ {
+ sigc::visit_each(_A_action, _A_target.functor_);
+ sigc::visit_each(_A_action, _A_target.bound_);
+ }
+};
#endif // DOXYGEN_SHOULD_SKIP_THIS
FOR(1,CALL_SIZE,[[BIND_FUNCTOR_COUNT(%1)]])dnl
@@ -393,7 +401,7 @@ FOR(1,CALL_SIZE,[[BIND_FUNCTOR_COUNT(%1)]])dnl
template <int I_location, class T_bound1, class T_functor>
inline bind_functor<I_location, T_functor, T_bound1>
bind(const T_functor& _A_func, T_bound1 _A_b1)
-{
+{
return bind_functor<I_location, T_functor, T_bound1>
(_A_func, _A_b1);
}
diff --git a/sigc++/adaptors/macros/bind_return.h.m4 b/sigc++/adaptors/macros/bind_return.h.m4
index 12d8e70..177e761 100644
--- a/sigc++/adaptors/macros/bind_return.h.m4
+++ b/sigc++/adaptors/macros/bind_return.h.m4
@@ -1,18 +1,18 @@
-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 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)
@@ -90,20 +90,24 @@ typename unwrap_reference<T_return>::type bind_return_functor<T_return, T_functo
{ this->functor_(); return ret_value_.invoke(); }
#ifndef DOXYGEN_SHOULD_SKIP_THIS
-//template specialization of visit_each<>(action, functor):
+//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::bind_return_functor performs a functor on the
* functor and on the object instance stored in the sigc::bind_return_functor object.
*
* @ingroup bind
*/
-template <class T_action, class T_return, class T_functor>
-void visit_each(const T_action& _A_action,
- const bind_return_functor<T_return, T_functor>& _A_target)
+template <class T_return, class T_functor>
+struct visitor<bind_return_functor<T_return, T_functor> >
{
- visit_each(_A_action, _A_target.ret_value_);
- visit_each(_A_action, _A_target.functor_);
-}
+ template <class T_action>
+ static void do_visit_each(const T_action& _A_action,
+ const bind_return_functor<T_return, T_functor>& _A_target)
+ {
+ sigc::visit_each(_A_action, _A_target.ret_value_);
+ sigc::visit_each(_A_action, _A_target.functor_);
+ }
+};
#endif // DOXYGEN_SHOULD_SKIP_THIS
/** Creates an adaptor of type sigc::bind_return_functor which fixes the return value of the passed functor
to the passed argument.
diff --git a/sigc++/adaptors/macros/compose.h.m4 b/sigc++/adaptors/macros/compose.h.m4
index 8e890ee..1b345f0 100644
--- a/sigc++/adaptors/macros/compose.h.m4
+++ b/sigc++/adaptors/macros/compose.h.m4
@@ -1,18 +1,18 @@
-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 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)
@@ -139,7 +139,7 @@ struct compose2_functor : public adapts<T_setter>
typedef T_setter setter_type;
typedef T_getter1 getter1_type;
typedef T_getter2 getter2_type;
-
+
#ifndef DOXYGEN_SHOULD_SKIP_THIS
template <LOOP(class T_arg%1=void, CALL_SIZE)>
struct deduce_result_type
@@ -176,50 +176,44 @@ compose2_functor<T_setter, T_getter1, T_getter2>::operator()()
{ return this->functor_(get1_(), get2_()); }
#ifndef DOXYGEN_SHOULD_SKIP_THIS
-//template specialization of visit_each<>(action, functor):
+//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::compose1_functor performs a functor on the
* functors stored in the sigc::compose1_functor object.
*
* @ingroup compose
*/
-template <class T_action, class T_setter, class T_getter>
-void visit_each(const T_action& _A_action,
- const compose1_functor<T_setter, T_getter>& _A_target)
+template <class T_setter, class T_getter>
+struct visitor<compose1_functor<T_setter, T_getter> >
{
- typedef compose1_functor<T_setter, T_getter> type_functor;
-
- //Note that the AIX compiler needs the actual template types of visit_each to be specified:
- typedef typename type_functor::setter_type type_functor1;
- visit_each<T_action, type_functor1>(_A_action, _A_target.functor_);
-
- typedef typename type_functor::getter_type type_functor_getter;
- visit_each<T_action, type_functor_getter>(_A_action, _A_target.get_);
-}
-
-//template specialization of visit_each<>(action, functor):
+ template <class T_action>
+ static void do_visit_each(const T_action& _A_action,
+ const compose1_functor<T_setter, T_getter>& _A_target)
+ {
+ sigc::visit_each(_A_action, _A_target.functor_);
+ sigc::visit_each(_A_action, _A_target.get_);
+ }
+};
+
+//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::compose2_functor performs a functor on the
* functors stored in the sigc::compose2_functor object.
*
* @ingroup compose
*/
-template <class T_action, class T_setter, class T_getter1, class T_getter2>
-void visit_each(const T_action& _A_action,
- const compose2_functor<T_setter, T_getter1, T_getter2>& _A_target)
+template <class T_setter, class T_getter1, class T_getter2>
+struct visitor<compose2_functor<T_setter, T_getter1, T_getter2> >
{
- typedef compose2_functor<T_setter, T_getter1, T_getter2> type_functor;
-
- //Note that the AIX compiler needs the actual template types of visit_each to be specified:
- typedef typename type_functor::setter_type type_functor1;
- visit_each<T_action, type_functor1>(_A_action, _A_target.functor_);
-
- typedef typename type_functor::getter1_type type_functor_getter1;
- visit_each<T_action, type_functor_getter1>(_A_action, _A_target.get1_);
-
- typedef typename type_functor::getter2_type type_functor_getter2;
- visit_each<T_action, type_functor_getter2>(_A_action, _A_target.get2_);
-}
+ template <class T_action>
+ static void do_visit_each(const T_action& _A_action,
+ const compose2_functor<T_setter, T_getter1, T_getter2>& _A_target)
+ {
+ sigc::visit_each(_A_action, _A_target.functor_);
+ sigc::visit_each(_A_action, _A_target.get1_);
+ sigc::visit_each(_A_action, _A_target.get2_);
+ }
+};
#endif // DOXYGEN_SHOULD_SKIP_THIS
/** Creates an adaptor of type sigc::compose1_functor which combines two functors.
diff --git a/sigc++/adaptors/macros/exception_catch.h.m4 b/sigc++/adaptors/macros/exception_catch.h.m4
index f9a9a73..f94581f 100644
--- a/sigc++/adaptors/macros/exception_catch.h.m4
+++ b/sigc++/adaptors/macros/exception_catch.h.m4
@@ -1,18 +1,18 @@
-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 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)
@@ -22,12 +22,12 @@ define([EXCEPTION_CATCH_OPERATOR],[dnl
template <LOOP(class T_arg%1, $1)>
typename deduce_result_type<LOOP(T_arg%1,$1)>::type
operator()(LOOP(T_arg%1 _A_a%1, $1))
- {
+ {
try
{
return this->functor_.SIGC_WORKAROUND_OPERATOR_PARENTHESES<LOOP(_P_(T_arg%1), $1)>
(LOOP(_A_a%1, $1));
- }
+ }
catch (...)
{ return catcher_(); }
}
@@ -52,7 +52,7 @@ namespace sigc {
will need to derive from catcher_base.
*/
/** @defgroup exception_catch exception_catch()
- * sigc::exception_catch() catches an exception thrown from within
+ * sigc::exception_catch() catches an exception thrown from within
* the wrapped functor and directs it to a catcher functor.
* This catcher can then rethrow the exception and catch it with the proper type.
*
@@ -111,13 +111,13 @@ FOR(1,CALL_SIZE,[[EXCEPTION_CATCH_OPERATOR(%1)]])dnl
: adapts<T_functor>(_A_func), catcher_(_A_catcher)
{}
- T_catcher catcher_;
+ T_catcher catcher_;
};
template <class T_functor, class T_catcher, class T_return>
typename exception_catch_functor<T_functor, T_catcher, T_return>::result_type
exception_catch_functor<T_functor, T_catcher, T_return>::operator()()
- {
+ {
try
{ return this->functor_(); }
catch (...)
@@ -142,12 +142,12 @@ FOR(1,CALL_SIZE,[[EXCEPTION_CATCH_OPERATOR(%1)]])dnl
{}
~exception_catch_functor() {}
- T_catcher catcher_;
+ T_catcher catcher_;
};
template <class T_functor, class T_catcher>
void exception_catch_functor<T_functor, T_catcher, void>::operator()()
- {
+ {
try
{ this->functor_(); } // I don't understand why void return doesn't work here (Martin)
catch (...)
@@ -155,14 +155,18 @@ void exception_catch_functor<T_functor, T_catcher, void>::operator()()
}
#ifndef DOXYGEN_SHOULD_SKIP_THIS
-//template specialization of visit_each<>(action, functor):
-template <class T_action, class T_functor, class T_catcher, class T_return>
-void visit_each(const T_action& _A_action,
- const exception_catch_functor<T_functor, T_catcher, T_return>& _A_target)
+//template specialization of visitor<>::do_visit_each<>(action, functor):
+template <class T_functor, class T_catcher, class T_return>
+struct visitor<exception_catch_functor<T_functor, T_catcher, T_return> >
{
- visit_each(_A_action, _A_target.functor_);
- visit_each(_A_action, _A_target.catcher_);
-}
+ template <typename T_action>
+ static void do_visit_each(const T_action& _A_action,
+ const exception_catch_functor<T_functor, T_catcher, T_return>& _A_target)
+ {
+ sigc::visit_each(_A_action, _A_target.functor_);
+ sigc::visit_each(_A_action, _A_target.catcher_);
+ }
+};
#endif // DOXYGEN_SHOULD_SKIP_THIS
template <class T_functor, class T_catcher>
diff --git a/sigc++/adaptors/macros/hide.h.m4 b/sigc++/adaptors/macros/hide.h.m4
index 3140323..26740e4 100644
--- a/sigc++/adaptors/macros/hide.h.m4
+++ b/sigc++/adaptors/macros/hide.h.m4
@@ -1,18 +1,18 @@
-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 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)
@@ -96,7 +96,7 @@ FOR(eval($1+1), $2,[
{ return
this->functor_.SIGC_WORKAROUND_OPERATOR_PARENTHESES<LIST(FOR(1,eval($1-1),[_P_(T_arg%1),]),FOR(eval($1+1),
$2,[_P_(T_arg%1),]))>
(LIST(FOR(1,eval($1-1),[_A_a%1,]),FOR(eval($1+1),$2,[_A_a%1,]))); }
#endif
-
+
])])dnl
])dnl end HIDE_OPERATOR
@@ -134,7 +134,7 @@ divert(0)dnl
_FIREWALL([ADAPTORS_HIDE])
#include <sigc++/adaptors/adaptor_trait.h>
-namespace sigc {
+namespace sigc {
/** @defgroup hide hide(), hide_return()
* sigc::hide() alters an arbitrary functor in that it adds a parameter
@@ -208,19 +208,23 @@ struct hide_functor {};
FOR(-1,eval(CALL_SIZE-1),[[HIDE_FUNCTOR(%1)]])dnl
#ifndef DOXYGEN_SHOULD_SKIP_THIS
-//template specialization of visit_each<>(action, functor):
+//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::hide_functor performs a functor on the
* functor stored in the sigc::hide_functor object.
*
* @ingroup hide
*/
-template <class T_action, int I_location, class T_functor>
-void visit_each(const T_action& _A_action,
- const hide_functor<I_location, T_functor>& _A_target)
+template <int I_location, class T_functor>
+struct visitor<hide_functor<I_location, T_functor> >
{
- visit_each(_A_action, _A_target.functor_);
-}
+ template <typename T_action>
+ static void do_visit_each(const T_action& _A_action,
+ const hide_functor<I_location, T_functor>& _A_target)
+ {
+ sigc::visit_each(_A_action, _A_target.functor_);
+ }
+};
#endif // DOXYGEN_SHOULD_SKIP_THIS
/** Creates an adaptor of type sigc::hide_functor which adds a dummy parameter to the passed functor.
diff --git a/sigc++/adaptors/macros/retype.h.m4 b/sigc++/adaptors/macros/retype.h.m4
index dda09b3..e3effc1 100644
--- a/sigc++/adaptors/macros/retype.h.m4
+++ b/sigc++/adaptors/macros/retype.h.m4
@@ -1,18 +1,18 @@
-dnl Copyright 2003, 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 Copyright 2003, 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)
@@ -21,7 +21,7 @@ include(template.macros.m4)
define([RETYPE_OPERATOR],[dnl
ifelse($1,0,[dnl
result_type operator()();
-
+
],[dnl
template <LOOP(class T_arg%1, $1)>
typename deduce_result_type<LOOP(T_arg%1,$1)>::type
@@ -162,19 +162,23 @@ retype_functor<LIST(T_functor, LOOP(T_type%1, CALL_SIZE))>::operator()()
{ return this->functor_(); }
#ifndef DOXYGEN_SHOULD_SKIP_THIS
-//template specialization of visit_each<>(action, functor):
+//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::retype_functor performs a functor on the
* functor stored in the sigc::retype_functor object.
*
* @ingroup retype
*/
-template <LIST(class T_action, class T_functor, LOOP(class T_type%1, CALL_SIZE))>
-void visit_each(const T_action& _A_action,
- const retype_functor<LIST(T_functor, LOOP(T_type%1, CALL_SIZE))>& _A_target)
+template <LIST(class T_functor, LOOP(class T_type%1, CALL_SIZE))>
+struct visitor<retype_functor<LIST(T_functor, LOOP(T_type%1, CALL_SIZE))> >
{
- visit_each(_A_action, _A_target.functor_);
-}
+ template <typename T_action>
+ static void do_visit_each(const T_action& _A_action,
+ const retype_functor<LIST(T_functor, LOOP(T_type%1, CALL_SIZE))>& _A_target)
+ {
+ sigc::visit_each(_A_action, _A_target.functor_);
+ }
+};
#endif // DOXYGEN_SHOULD_SKIP_THIS
/** Creates an adaptor of type sigc::retype_functor which performs C-style casts on the parameters passed on
to the functor.
diff --git a/sigc++/adaptors/macros/retype_return.h.m4 b/sigc++/adaptors/macros/retype_return.h.m4
index 7bcec1c..cf13b98 100644
--- a/sigc++/adaptors/macros/retype_return.h.m4
+++ b/sigc++/adaptors/macros/retype_return.h.m4
@@ -1,18 +1,18 @@
-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 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)
@@ -32,7 +32,7 @@ define([RETYPE_RETURN_OPERATOR],[dnl
(LOOP(_A_a%1, $1)));
}
#endif
-
+
])
define([RETYPE_RETURN_VOID_OPERATOR],[dnl
template <LOOP(class T_arg%1, $1)>
@@ -126,19 +126,23 @@ void retype_return_functor<void, T_functor>::operator()()
{ this->functor_(); }
#ifndef DOXYGEN_SHOULD_SKIP_THIS
-//template specialization of visit_each<>(action, functor):
+//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::retype_return_functor performs a functor on the
* functor stored in the sigc::retype_return_functor object.
*
* @ingroup retype
*/
-template <class T_action, class T_return, class T_functor>
-void visit_each(const T_action& _A_action,
- const retype_return_functor<T_return, T_functor>& _A_target)
+template <class T_return, class T_functor>
+struct visitor<retype_return_functor<T_return, T_functor> >
{
- visit_each(_A_action, _A_target.functor_);
-}
+ template <typename T_action>
+ static void do_visit_each(const T_action& _A_action,
+ const retype_return_functor<T_return, T_functor>& _A_target)
+ {
+ sigc::visit_each(_A_action, _A_target.functor_);
+ }
+};
#endif // DOXYGEN_SHOULD_SKIP_THIS
/** Creates an adaptor of type sigc::retype_return_functor which performs a C-style cast on the return value
of the passed functor.
diff --git a/sigc++/adaptors/macros/track_obj.h.m4 b/sigc++/adaptors/macros/track_obj.h.m4
index 632b8f5..78583b1 100644
--- a/sigc++/adaptors/macros/track_obj.h.m4
+++ b/sigc++/adaptors/macros/track_obj.h.m4
@@ -85,7 +85,7 @@ FOR(2,$1,[
])dnl end TRACK_OBJECT_FUNCTOR
define([TRACK_OBJECT_VISIT_EACH],[dnl
-//template specialization of visit_each<>(action, functor):
+//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::track_obj_functor$1 performs a functor
* on the functor and on the trackable object instances stored in the
@@ -95,14 +95,18 @@ define([TRACK_OBJECT_VISIT_EACH],[dnl
*
* @ingroup track_obj
*/
-template <typename T_action, typename T_functor, LOOP(typename T_obj%1, $1)>
-void visit_each(const T_action& _A_action,
- const track_obj_functor$1<T_functor, LOOP(T_obj%1, $1)>& _A_target)
+template <typename T_functor, LOOP(typename T_obj%1, $1)>
+struct visitor<track_obj_functor$1<T_functor, LOOP(T_obj%1, $1)> >
{
- sigc::visit_each(_A_action, _A_target.functor_);dnl
+ template <typename T_action>
+ static void do_visit_each(const T_action& _A_action,
+ const track_obj_functor$1<T_functor, LOOP(T_obj%1, $1)>& _A_target)
+ {
+ sigc::visit_each(_A_action, _A_target.functor_);dnl
FOR(1,$1,[
- sigc::visit_each(_A_action, _A_target.obj%1_);])
-}
+ sigc::visit_each(_A_action, _A_target.obj%1_);])
+ }
+};
])dnl end TRACK_OBJECT_VISIT_EACH
@@ -135,7 +139,7 @@ _FIREWALL([ADAPTORS_TRACK_OBJ])
namespace sigc {
/** @defgroup track_obj track_obj()
- * track_obj() tracks trackable objects, referenced from a functor.
+ * sigc::track_obj() tracks trackable objects, referenced from a functor.
* It can be useful when you assign a C++11 lambda expression or a std::function<>
* to a slot, or connect it to a signal, and the lambda expression or std::function<>
* contains references to sigc::trackable derived objects.
diff --git a/sigc++/functors/macros/mem_fun.h.m4 b/sigc++/functors/macros/mem_fun.h.m4
index 814aa56..2763796 100644
--- a/sigc++/functors/macros/mem_fun.h.m4
+++ b/sigc++/functors/macros/mem_fun.h.m4
@@ -1,18 +1,18 @@
-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 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)
@@ -122,19 +122,23 @@ FOR(1, $1,[
};
#ifndef DOXYGEN_SHOULD_SKIP_THIS
-//template specialization of visit_each<>(action, functor):
+//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_[$2]mem_functor performs a functor
* on the object instance stored in the sigc::bound_[$2]mem_functor object.
*
* @ingroup mem_fun
*/
-template <LIST(class T_action, class T_return, class T_obj, LOOP(class T_arg%1, $1))>
-void visit_each(const T_action& _A_action,
- const bound_[$2]mem_functor$1<LIST(T_return, T_obj, LOOP(T_arg%1, $1))>& _A_target)
+template <LIST(class T_return, class T_obj, LOOP(class T_arg%1, $1))>
+struct visitor<bound_[$2]mem_functor$1<LIST(T_return, T_obj, LOOP(T_arg%1, $1))> >
{
- sigc::visit_each(_A_action, _A_target.obj_);
-}
+ template <class T_action>
+ static void do_visit_each(const T_action& _A_action,
+ const bound_[$2]mem_functor$1<LIST(T_return, T_obj, LOOP(T_arg%1, $1))>&
_A_target)
+ {
+ sigc::visit_each(_A_action, _A_target.obj_);
+ }
+};
#endif // DOXYGEN_SHOULD_SKIP_THIS
])
@@ -180,7 +184,7 @@ mem_fun[]ifelse($2,, $1)(/*$4*/ T_obj& _A_obj, T_return (T_obj2::*_A_func)(LOOP(
divert(0)
-// implementation notes:
+// 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.
diff --git a/sigc++/functors/macros/slot.h.m4 b/sigc++/functors/macros/slot.h.m4
index 4a85e44..eea7bf2 100644
--- a/sigc++/functors/macros/slot.h.m4
+++ b/sigc++/functors/macros/slot.h.m4
@@ -1,18 +1,18 @@
-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 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)
@@ -197,7 +197,7 @@ ifelse($1,0,[
/** Forms a function pointer from call_it().
* @return A function pointer formed from call_it().
*/
- static hook address()
+ static hook address()
{ return reinterpret_cast<hook>(&call_it); }
};
@@ -239,17 +239,17 @@ struct typed_slot_rep : public slot_rep
*/
inline typed_slot_rep(const T_functor& functor)
: slot_rep(0, &destroy, &dup), functor_(functor)
- { visit_each_type<trackable*>(slot_do_bind(this), functor_); }
+ { sigc::visit_each_type<trackable*>(slot_do_bind(this), functor_); }
inline typed_slot_rep(const typed_slot_rep& cl)
: slot_rep(cl.call_, &destroy, &dup), functor_(cl.functor_)
- { visit_each_type<trackable*>(slot_do_bind(this), functor_); }
+ { sigc::visit_each_type<trackable*>(slot_do_bind(this), functor_); }
inline ~typed_slot_rep()
{
call_ = 0;
destroy_ = 0;
- visit_each_type<trackable*>(slot_do_unbind(this), functor_);
+ sigc::visit_each_type<trackable*>(slot_do_unbind(this), functor_);
}
/** Detaches the stored functor from the other referred trackables and destroys it.
@@ -260,7 +260,7 @@ struct typed_slot_rep : public slot_rep
self* self_ = static_cast<self*>(reinterpret_cast<slot_rep*>(data));
self_->call_ = 0;
self_->destroy_ = 0;
- visit_each_type<trackable*>(slot_do_unbind(self_), self_->functor_);
+ sigc::visit_each_type<trackable*>(slot_do_unbind(self_), self_->functor_);
self_->functor_.~adaptor_type();
/* don't call disconnect() here: destroy() is either called
* a) from the parent itself (in which case disconnect() leads to a segfault) or
diff --git a/sigc++/macros/limit_reference.h.m4 b/sigc++/macros/limit_reference.h.m4
index 1780611..802446c 100644
--- a/sigc++/macros/limit_reference.h.m4
+++ b/sigc++/macros/limit_reference.h.m4
@@ -1,19 +1,18 @@
+dnl Copyright 2002, The libsigc++ Development Team
dnl
-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 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)
@@ -35,7 +34,7 @@ define([LIMIT_REFERENCE],[dnl
* If Foo does not inherit from sigc::trackable then invoke() and visit() just return the
* derived reference.
*
- * This is used for bound (sigc::bind) slot parameters (via bound_argument), bound return values,
+ * This is used for bound (sigc::bind) slot parameters (via bound_argument), bound return values,
* and, with mem_fun(), the reference to the handling object.
*
* - @e T_type The type of the reference.
@@ -113,21 +112,24 @@ private:
};
#ifndef DOXYGEN_SHOULD_SKIP_THIS
-/** Implementation of visit_each() specialized for the [$1]limit_reference
+/** Implementation of visitor specialized for the [$1]limit_reference
* class, to call visit_each() on the entity returned by the [$1]limit_reference's
* visit() method.
- * - @e T_action The type of functor to invoke.
- * - @e T_type The type of the reference.
+ * @tparam T_type The type of the reference.
+ * @tparam T_action The type of functor to invoke.
* @param _A_action The functor to invoke.
* @param _A_target The visited instance.
*/
-template <class T_action, class T_type, bool I_derives_trackable>
-void
-visit_each(const T_action& _A_action,
- const [$1]limit_reference<T_type, I_derives_trackable>& _A_target)
+template <class T_type, bool I_derives_trackable>
+struct visitor<[$1]limit_reference<T_type, I_derives_trackable> >
{
- visit_each(_A_action, _A_target.visit());
-}
+ template <class T_action>
+ static void do_visit_each(const T_action& _A_action,
+ const [$1]limit_reference<T_type, I_derives_trackable>& _A_target)
+ {
+ sigc::visit_each(_A_action, _A_target.visit());
+ }
+};
#endif // DOXYGEN_SHOULD_SKIP_THIS
])
diff --git a/sigc++/visit_each.h b/sigc++/visit_each.h
index 70d7522..d89d7c2 100644
--- a/sigc++/visit_each.h
+++ b/sigc++/visit_each.h
@@ -1,4 +1,3 @@
-// -*- c++ -*-
/*
* Copyright 2002, The libsigc++ Development Team
*
@@ -15,7 +14,6 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
*/
#ifndef _SIGC_VISIT_EACH_HPP_
#define _SIGC_VISIT_EACH_HPP_
@@ -55,7 +53,6 @@ struct limit_derived_target
{
typedef limit_derived_target<T_target, T_action> T_self;
-
template <class T_type>
void operator()(const T_type& _A_type) const
{
@@ -85,7 +82,7 @@ struct with_type_pointer<false, T_type, T_limit>
template <class T_type, class T_limit>
struct with_type_pointer<true, T_type, T_limit>
{
- static void execute_(const T_type& _A_type, const T_limit& _A_action)
+ static void execute_(const T_type& _A_type, const T_limit& _A_action)
{ _A_action.action_(&_A_type); }
};
@@ -94,7 +91,6 @@ struct limit_derived_target<T_target*, T_action>
{
typedef limit_derived_target<T_target*, T_action> T_self;
-
template <class T_type>
void operator()(const T_type& _A_type) const
{
@@ -111,38 +107,66 @@ struct limit_derived_target<T_target*, T_action>
} /* namespace internal */
#endif // DOXYGEN_SHOULD_SKIP_THIS
-/** This function performs a functor on each of the targets of a functor.
- * All unknown types just call @e _A_action on them.
- * Add overloads that specialize the @e T_functor argument for your own
+// struct visitor was introduced as a result of https://bugzilla.gnome.org/show_bug.cgi?id=724496
+// The advantage of using specializations of a template struct instead of overloads of
+// a template function is described by Herb Sutter in http://www.gotw.ca/publications/mill17.htm
+// In libsigc++ the main reason for using this technique is that we can avoid using ADL
+// (argument-dependent lookup), and therefore there is no risk that a visit_each() overload
+// in e.g. Boost is selected by mistake.
+
+/** sigc::visitor<T_functor>::do_visit_each() performs a functor on each of the targets of a functor.
+ * All unknown types just call @a _A_action on them.
+ * Add specializations that specialize the @a T_functor argument for your own
* functor types, so that subobjects get visited. This is needed to enable
* auto-disconnection support for your functor types.
*
* @par Example:
* @code
- * struct some_functor
+ * namespace some_ns
* {
- * void operator()() {}
- * some_possibly_sigc_trackable_derived_type some_data_member;
- * some_other_functor_type some_other_functor;
+ * struct some_functor
+ * {
+ * void operator()() {}
+ * some_possibly_sigc_trackable_derived_type some_data_member;
+ * some_other_functor_type some_other_functor;
+ * };
* }
*
* namespace sigc
* {
- * template <class T_action>
- * void visit_each(const T_action& _A_action,
- * const some_functor& _A_target)
+ * template <>
+ * struct visitor<some_ns::some_functor>
* {
- * visit_each(_A_action, _A_target.some_data_member);
- * visit_each(_A_action, _A_target.some_other_functor);
- * }
+ * template <class T_action>
+ * static void do_visit_each(const T_action& _A_action,
+ * const some_ns::some_functor& _A_target)
+ * {
+ * sigc::visit_each(_A_action, _A_target.some_data_member);
+ * sigc::visit_each(_A_action, _A_target.some_other_functor);
+ * }
+ * };
* }
* @endcode
*
* @ingroup sigcfunctors
*/
+template <class T_functor>
+struct visitor
+{
+ template <class T_action>
+ static void do_visit_each(const T_action& _A_action, const T_functor& _A_functor)
+ {
+ _A_action(_A_functor);
+ }
+};
+
+/** This function performs a functor on each of the targets of a functor.
+ *
+ * @ingroup sigcfunctors
+ */
template <class T_action, class T_functor>
void visit_each(const T_action& _A_action, const T_functor& _A_functor)
-{ _A_action(_A_functor); }
+{ sigc::visitor<T_functor>::do_visit_each(_A_action, _A_functor); }
/** This function performs a functor on each of the targets
* of a functor limited to a restricted type.
@@ -151,7 +175,7 @@ void visit_each(const T_action& _A_action, const T_functor& _A_functor)
*/
template <class T_type, class T_action, class T_functor>
void visit_each_type(const T_action& _A_action, const T_functor& _A_functor)
-{
+{
typedef internal::limit_derived_target<T_type, T_action> type_limited_action;
type_limited_action limited_action(_A_action);
@@ -162,13 +186,19 @@ void visit_each_type(const T_action& _A_action, const T_functor& _A_functor)
//
//But this is required by the AIX (and maybe IRIX MipsPro and Tru64) compilers.
//I guess that sigc::ref() therefore does not work on those platforms. murrayc
- //visit_each<type_limited_action, T_functor>(limited_action, _A_functor);
+ // sigc::visit_each<type_limited_action, T_functor>(limited_action, _A_functor);
- //g++ (even slightly old ones) is our primary platform, so we could use the non-crashing version.
- //However, the expliict version also fixes a crash in a slightl more common case:
http://bugzilla.gnome.org/show_bug.cgi?id=169225
- //Users (and distributors) of libsigc++ on AIX (and maybe IRIX MipsPro and Tru64) do
+ //g++ (even slightly old ones) is our primary platform, so we could use the non-crashing version.
+ //However, the explicit version also fixes a crash in a slightly more common case:
http://bugzilla.gnome.org/show_bug.cgi?id=169225
+ //Users (and distributors) of libsigc++ on AIX (and maybe IRIX MipsPro and Tru64) do
//need to use the version above instead, to allow compilation.
- visit_each(limited_action, _A_functor);
+
+ //Added 2014-03-20: The preceding comment probably does not apply any more,
+ //now when the visit_each<>() overloads have been replaced by visitor<> specializations.
+ //It's probably safe to add explicit template parameters on calls to visit_each(),
+ //visit_each_type() and visitor::do_visit_each(), if necessary.
+
+ sigc::visit_each(limited_action, _A_functor);
}
} /* namespace sigc */
diff --git a/tests/test_functor_trait.cc b/tests/test_functor_trait.cc
index c324b67..10a9fe1 100644
--- a/tests/test_functor_trait.cc
+++ b/tests/test_functor_trait.cc
@@ -1,4 +1,3 @@
-// -*- c++ -*-
/* Copyright 2002, The libsigc++ Development Team
* Assigned to public domain. Use as you wish without restriction.
*/
@@ -54,7 +53,7 @@ struct print
{
void operator()(int i) const
{
- result_stream << "int: " << i;
+ result_stream << "int: " << i << " ";
}
template <class T>
@@ -85,15 +84,15 @@ int main(int argc, char* argv[])
A a;
result_stream << "hit all targets: ";
sigc::visit_each(print(), sigc::compose(sigc::bind(sigc::ptr_fun3(&foo), sigc::ref(a), i),
sigc::ptr_fun1(&bar)));
- util->check_result(result_stream, "hit all targets: other other ");
+ util->check_result(result_stream, "hit all targets: other trackable int: 1 other ");
result_stream << "hit all ints: ";
sigc::visit_each_type<int>(print(), sigc::compose(sigc::bind(sigc::ptr_fun3(&foo), sigc::ref(a),
j),sigc::ptr_fun1(&bar)));
- util->check_result(result_stream, "hit all ints: ");
+ util->check_result(result_stream, "hit all ints: int: 2 ");
result_stream << "hit all trackable: ";
sigc::visit_each_type<trackable>(print(), sigc::compose(sigc::bind(sigc::ptr_fun3(&foo), sigc::ref(a),
k),sigc::ptr_fun1(&bar)));
- util->check_result(result_stream, "hit all trackable: ");
+ util->check_result(result_stream, "hit all trackable: trackable ");
return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]