// Simple version of std::bind that doesn't support placeholders #pragma once #include #include // __bind_call generates a list of integers 0 .. N-1 ... template struct __bind_call { static Res call(F& f, TArgs& t) { return __bind_call::call(f, t); } }; // ... which the __bind_call base case unpacks to get a sequence of // tuple indexes to pass to std::get to extract the saved arguments // from the tuple t. template struct __bind_call<0, F, Res, TArgs, list...> { static Res call(F& f, TArgs& t) { return f(std::get(t)...); } }; template struct __bind_helper { typedef std::tuple::type...> TArgs; F f_; TArgs args_; __bind_helper(F&& f, Args&&... args) : f_(f), args_(args...) { } Res operator()() { return __bind_call:: call(f_, args_); } }; template auto bind_simple(F&& f, Args&&... args) -> __bind_helper { return __bind_helper( std::forward(f), std::forward(args)...); }