-
Notifications
You must be signed in to change notification settings - Fork 182
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
Add support for function references (free and static member) in bind_back #605
Add support for function references (free and static member) in bind_back #605
Conversation
Hi @denizevrenci! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
09fef2e
to
59c8dd0
Compare
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of nits regarding the tests, but I think we should chat about the new callable
specialization.
59c8dd0
to
b2066dc
Compare
cecc1ec
to
628964c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good!
628964c
to
28dd29e
Compare
28dd29e
to
4ab5ef2
Compare
These are drop in replacements of is_callable variants and we can replace our concept shim with them as well.
These assertions are usually followed by other expressions assuming that they are passing and in case a change breaks them they potentially trigger undefined behavior with `EXCEPT_TRUE`.
…back The following program does not compile: https://godbolt.org/z/WfhEc51dY But if we replace the function reference with a lambda, it does: https://godbolt.org/z/jrhTY4nse Constructing a std::tuple with a function type fails but function pointers are allowed. We instantiate _result with std::decay_t<ArgN>... which maps function references to function pointers and then the corresponding std::tuple instantiation does not fail to compile. The problem with the existing code is that, in order to instantiate std::tuple<std::decay_t<ArgN>...>, we first constructed a std::tuple<ArgN> and passed it over. If instead we construct a std::tuple<std::decay_t<ArgN>...> with the function arguments, they will be converted to function pointers and the std::tuple instantiation will compile.
4ab5ef2
to
22bcfd1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
The following program does not compile: https://godbolt.org/z/WfhEc51dY But if we replace the function reference with a lambda, it does: https://godbolt.org/z/jrhTY4nse Constructing a std::tuple with a function type fails but function pointers are allowed. We instantiate _result with std::decay_t... which maps function references to function pointers and then the corresponding std::tuple instantiation does not fail to compile. The problem with the existing code is that, in order to instantiate std::tuple<std::decay_t...>, we first constructed a std::tuple and passed it over. If instead we construct a std::tuple<std::decay_t...> with the function arguments, they will be converted to function pointers and the std::tuple instantiation will compile.