/* { dg-do compile } */ /* { dg-options "-O2" } */ namespace sigc { template struct type_trait { typedef T_type& pass; typedef const T_type& take; typedef T_type* pointer; }; template struct type_trait { typedef T_type& pass; }; template<> struct type_trait { typedef void pass; }; template struct is_base_and_derived { struct big { char memory[64]; }; static big is_base_class_(...); static char is_base_class_(typename type_trait::pointer); static const bool value = sizeof(is_base_class_(reinterpret_cast::pointer>(0))) == sizeof(char); }; struct nil; struct functor_base { }; template ::value> struct functor_trait { typedef typename T_functor::result_type result_type; typedef T_functor functor_type; }; struct adaptor_base : public functor_base { }; template ::value> struct deduce_result_type { typedef typename functor_trait::result_type type; }; template struct adaptor_functor : public adaptor_base { template struct deduce_result_type { typedef typename sigc::deduce_result_type::type type; }; typedef typename functor_trait::result_type result_type; template typename deduce_result_type::type operator()(T_arg1 _A_arg1,T_arg2 _A_arg2) const { return functor_(_A_arg1,_A_arg2); } explicit adaptor_functor(const T_functor& _A_functor) : functor_(_A_functor) { } mutable T_functor functor_; }; template ::value> struct adaptor_trait; template struct adaptor_trait { typedef T_functor adaptor_type; }; template struct adaptor_trait { typedef typename functor_trait::functor_type functor_type; typedef adaptor_functor adaptor_type; }; template struct adapts : public adaptor_base { typedef typename adaptor_trait::adaptor_type adaptor_type; explicit adapts(const T_functor& _A_functor) : functor_(_A_functor) { } mutable adaptor_type functor_; }; template struct unwrap_reference { typedef T_type type; }; template class bound_argument { public: bound_argument(const T_type& _A_argument) : visited_(_A_argument) { } inline T_type& invoke() { } T_type visited_; }; template struct bind_functor; template struct bind_functor<0, T_functor, T_bound, nil,nil,nil,nil,nil,nil> : public adapts { typedef typename adapts::adaptor_type adaptor_type; template struct deduce_result_type { typedef typename adaptor_type::template deduce_result_type::type>::pass, typename type_trait::pass, typename type_trait::pass, typename type_trait::pass, typename type_trait::pass, typename type_trait::pass, typename type_trait::pass>::type type; }; typedef typename adaptor_type::result_type result_type; result_type operator()() { return this->functor_.template operator()::type>::pass> (bound_.invoke()); } template typename deduce_result_type::type operator()(T_arg1 _A_arg1) { return this->functor_.template operator()::type>::pass, typename type_trait::pass> (bound_.invoke(), _A_arg1); } bind_functor(typename type_trait::take _A_func, typename type_trait::take _A_bound) : adapts(_A_func), bound_(_A_bound) { } bound_argument bound_; }; template inline bind_functor bind(const T_functor& _A_func, T_bound1 _A_b1) { return bind_functor(_A_func, _A_b1); }; } struct foo { typedef int result_type; int operator()(int i, int j); }; int main() { sigc::bind<0>(sigc::bind<0>(foo(),7),8)(); }