#include #include #include template struct indices {}; template struct build_indices : build_indices {}; template struct build_indices<0, Is...> : indices {}; template struct placeholder{}; namespace std{ template struct is_placeholder< ::placeholder> : std::integral_constant{}; } // std:: namespace detail{ template auto my_bind(indices, Ret (Fn::*f)(MArgs...), Fn *i, Args&&... args) -> decltype(std::bind(f, i, std::forward(args)..., placeholder<1 + Is>{}...)){ return std::bind(f, i, std::forward(args)..., placeholder<1 + Is>{}...); } } template auto my_bind(std::function, Ret (Fn::*f)(MArgs...), Fn *i, Args&&... args) -> decltype(detail::my_bind(build_indices{}, f, i, std::forward(args)...)){ return detail::my_bind(build_indices{}, f, i, std::forward(args)...); } #include struct tmp{ void testt(int var1, int var2){ std::cout << var1 << " " << var2 << std::endl; } }; int main(){ tmp TMP; auto f3 = my_bind(std::function(), &tmp::testt, &TMP); f3(22, 23); }