Skip to content

Instantly share code, notes, and snippets.

@Pibben
Created October 2, 2019 09:31
Show Gist options
  • Save Pibben/c6a199ac057e3f61e4db3cf1852cef57 to your computer and use it in GitHub Desktop.
Save Pibben/c6a199ac057e3f61e4db3cf1852cef57 to your computer and use it in GitHub Desktop.
template<class T, class R, class... Args>
struct mem_fn_wrap {
R (T::* pm)(Args...);
T& t;
mem_fn_wrap(R (T::* pm)(Args...), T& t) : pm(pm), t(t) {}
R operator()(Args&&... args) {
return (t.*pm)(std::forward<Args>(args)...);
}
};
template<class T, class R, class... Args>
mem_fn_wrap(R (T::*)(Args...), T&) -> mem_fn_wrap<T, R, Args...>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment