Skip to content

Instantly share code, notes, and snippets.

@rightfold
Created April 5, 2015 13:56
Show Gist options
  • Save rightfold/483e57cd77114e81fac6 to your computer and use it in GitHub Desktop.
Save rightfold/483e57cd77114e81fac6 to your computer and use it in GitHub Desktop.
set_global("std::bind", [] (auto arguments_begin, auto arguments_end) {
auto callee = *arguments_begin;
std::vector<handle> bound_arguments(arguments_begin + 1, arguments_end);
return handle(subroutine(
[callee = std::move(callee), bound_arguments = std::move(bound_arguments)]
(auto new_arguments_begin, auto new_arguments_end) {
auto arguments = bound_arguments;
arguments.insert(arguments.end(), new_arguments_begin, new_arguments_end);
return callee->template data<subroutine>()(arguments.begin(), arguments.end());
}
));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment