// -*- c++ -*- /* Copyright 2002, The libsigc++ Development Team * Assigned to public domain. Use as you wish without restriction. */ #include #include #include #include #include SIGC_USING_STD(cout) SIGC_USING_STD(endl) class trackable {}; struct A: public trackable { A() {} }; template ::value> struct with_trackable; template struct with_trackable { static void perform(const T_type& t) { std::cout << "other" < struct with_trackable { static void perform(const T_type& t) { std::cout << "trackable" << std::endl; } static void perform(T_type* t) { std::cout << "trackable*" << std::endl; } static void perform(const T_type* t) { std::cout << "const trackable*" << std::endl; } }; struct print { void operator()(int i) const { std::cout << "int: "<< i << std::endl; } template void operator()(const T& t) const { with_trackable::perform(t); } }; void foo(int i,int j,int k) {} void bar(int i) {} 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), sigc::ref(a), j), sigc::ptr_fun1(&bar))); std::cout << "hit all ints" << std::endl; sigc::visit_each_type(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(print(), sigc::compose(sigc::bind(sigc::ptr_fun3(&foo), sigc::ref(a), j),sigc::ptr_fun1(&bar))); }