Skip to content

Instantly share code, notes, and snippets.

@shoooe
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shoooe/2fa1b9566b4efbcbd477 to your computer and use it in GitHub Desktop.
Save shoooe/2fa1b9566b4efbcbd477 to your computer and use it in GitHub Desktop.
Simple implementation for partial function application in C++ (only works without overloaded functions, of course).
#include <utility>
template<class Func, class... Args>
auto apply(Func fn, Args&&... args) {
return [&](auto&&... sargs) {
return fn
( std::forward<decltype(args)>(args)...
, std::forward<decltype(sargs)>(sargs)... );
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment