Skip to content

class_<T>.constructor to accept std::function and function object #9051

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

hkleynhans
Copy link
Contributor

Enable class_<T>.constructor to accept both std::function and
function object types. This is useful in scenarios where you want a
stateful function object for purposes such as gathering statistics or
performing other generic functionality on each call.

@hkleynhans
Copy link
Contributor Author

@Brion , @wingo - Here is the next patch expanding support for taking bsl::function and function objects on the embind interface. Please take a look.

Enable `class_<T>.constructor` to accept both `std::function` and
function object types. This is useful in scenarios where you want a
stateful function object for purposes such as gathering statistics or
performing other generic functionality on each call.
@hkleynhans hkleynhans force-pushed the functors_as_class_constructors branch from b5146ce to 2f70512 Compare July 22, 2019 16:27
Copy link
Contributor

@wingo wingo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Nice simplification to fold the ThisType param into the arguments.

@kripken
Copy link
Member

kripken commented Jul 25, 2019

Thanks for the PR @hkleynhans! And thanks for reviewing @wingo!

@kripken kripken merged commit ecb7bb3 into emscripten-core:incoming Jul 25, 2019
@hkleynhans
Copy link
Contributor Author

Thanks @wingo , @kripken !

@aminya
Copy link
Contributor

aminya commented Dec 5, 2020

#12973 reverts a part of this PR that broke a couple of other projects.

cc: @hkleynhans

belraquib pushed a commit to belraquib/emscripten that referenced this pull request Dec 23, 2020
…on object (emscripten-core#9051)

Enable `class_<T>.constructor` to accept both `std::function` and
function object types. This is useful in scenarios where you want a
stateful function object for purposes such as gathering statistics or
performing other generic functionality on each call.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants