diff options
| author | Martin Schulze <teebaum@cvs.gnome.org> | 2004-02-27 21:05:43 +0000 |
|---|---|---|
| committer | Martin Schulze <teebaum@src.gnome.org> | 2004-02-27 21:05:43 +0000 |
| commit | 994d887f6408582d3fdad9968e477b30ba0b098b (patch) | |
| tree | 451d977e5ee4f87547b9f6ef34492d84e49c6362 | |
| parent | 1f61f9a29b92a13ec3861c867a4132f73d060d43 (diff) | |
| download | sigc++-994d887f6408582d3fdad9968e477b30ba0b098b.tar.gz | |
Bring it up-to-date (use sigc::ref). Make it work with the SUN Forte.
2004-02-27 Martin Schulze <teebaum@cvs.gnome.org>
* tests/type_functor_trait.cc: Bring it up-to-date (use sigc::ref).
Make it work with the SUN Forte.
| -rw-r--r-- | ChangeLog | 5 | ||||
| -rw-r--r-- | tests/test_functor_trait.cc | 23 |
2 files changed, 14 insertions, 14 deletions
@@ -1,3 +1,8 @@ +2004-02-27 Martin Schulze <teebaum@cvs.gnome.org> + + * tests/type_functor_trait.cc: Bring it up-to-date (use sigc::ref). + Make it work with the SUN Forte. + 2004-02-24 Martin Schulze <teebaum@cvs.gnome.org> * sigc++/type_traits.h: Make is_base_and_derived<> work with the SUN Forte. diff --git a/tests/test_functor_trait.cc b/tests/test_functor_trait.cc index d12c3a8..dd48fce 100644 --- a/tests/test_functor_trait.cc +++ b/tests/test_functor_trait.cc @@ -12,17 +12,18 @@ class trackable {}; struct A: public trackable { A() {} }; -template <bool I_derived, class T_type> struct with_trackable; +template <class T_type, bool I_derived = sigc::is_base_and_derived<trackable,T_type>::value> +struct with_trackable; template <class T_type> -struct with_trackable<false,T_type> +struct with_trackable<T_type,false> { static void perform(const T_type& t) { std::cout << "other" <<std::endl; } }; template <class T_type> -struct with_trackable<true,T_type> +struct with_trackable<T_type,true> { static void perform(const T_type& t) { std::cout << "trackable" << std::endl; } @@ -35,16 +36,10 @@ struct with_trackable<true,T_type> struct print { void operator()(int i) const - { std::cout << "int "<< i << std::endl; } + { std::cout << "int: "<< i << std::endl; } template <class T> void operator()(const T& t) const - { with_trackable<sigc::is_base_and_derived<trackable,T>::value, T>::perform(t); } - template <class T> - void operator()(const T* t) const - { with_trackable<sigc::is_base_and_derived<trackable,T>::value, T>::perform(t); } - template <class T> - void operator()(T* t) const - { with_trackable<sigc::is_base_and_derived<trackable,T>::value, T>::perform(t); } + { with_trackable<T>::perform(t); } }; void foo(int i,int j,int k) @@ -58,9 +53,9 @@ int main() int i=1,j=2,k=3; A a; std::cout << "hit all targets" << std::endl; - sigc::visit_each(print(), sigc::compose(sigc::bind(sigc::ptr_fun3(&foo), &a, j), sigc::ptr_fun1(&bar))); + sigc::visit_each(print(), sigc::compose(sigc::bind(sigc::ptr_fun3(&foo), sigc::ref(a), j), sigc::ptr_fun1(&bar))); std::cout << "hit all ints" << std::endl; - sigc::visit_each_type<int>(print(),sigc::compose(sigc::bind(sigc::ptr_fun3(&foo), &a, j),sigc::ptr_fun1(&bar))); + sigc::visit_each_type<int>(print(),sigc::compose(sigc::bind(sigc::ptr_fun3(&foo), sigc::ref(a), j),sigc::ptr_fun1(&bar))); std::cout << "hit all trackable" << std::endl; - sigc::visit_each_type<trackable*>(print(), sigc::compose(sigc::bind(sigc::ptr_fun3(&foo), &a, j),sigc::ptr_fun1(&bar))); + sigc::visit_each_type<trackable>(print(), sigc::compose(sigc::bind(sigc::ptr_fun3(&foo), sigc::ref(a), j),sigc::ptr_fun1(&bar))); } |
