Introducing folly::partial
Summary: This diff adds folly::partial, a function to partially apply a set of zero or more arguments to a callable. It is similar to Python's `functools.partial`. `folly::partial` takes a callable object and additional arguments and returns a callable with those additional arguments bound to it. When the returned callable is invoked with additional arguments, those are appended to the set of arguments that were passed to `folly::partial`. It is similar to `std::bind`, but more simple as it does not support reordering of parameters, but also does not require you to know how many arguments will be eventually passed to the callable. Also, `std::bind` does not support move-only types being passed by-value. `folly::partial` does: void someFunc(std::unique_ptr<Foo>, int); auto p = folly::partial(&someFunc, std::move(foo_unique_ptr)); ... std::move(p)(42); Reviewed By: mhx Differential Revision: D3252539 fbshipit-source-id: ee093771ac732fa70052b9908dcb75e90ba80efe
Showing
folly/Partial.h
0 → 100644
folly/test/PartialTest.cpp
0 → 100644
Please register or sign in to comment