-
Notifications
You must be signed in to change notification settings - Fork 52
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
[inplace_function] Should [](){return 42;} be convertible to inplace_function<void()>? #150
Comments
…n important part).
Survey of existing practice (that is, of people who provide a single-header implementation, because I'm lazy): https://godbolt.org/z/PGx6JA
https://github.com/TartanLlama/function_ref https://github.com/Naios/function2 After #155, I'd be interested to learn what happens with |
Before this patch, we reported that `is_convertible<int(*)(), inplace_function<void()>>`, but if you actually tried to do it, you got a compiler error down in the guts of `inplace_function`. After this patch, we let you do it. However, see issue WG21-SG14#150: I think anyone who relies on this behavior is probably doing so unintentionally (and their code is probably wrong). Therefore, maybe we should change our SFINAE so that `is_convertible<int(*)(), inplace_function<void()>>` would be `false`.
Before this patch, we reported that `is_convertible<int(*)(), inplace_function<void()>>`, but if you actually tried to do it, you got a compiler error down in the guts of `inplace_function`. After this patch, we let you do it. However, see issue WG21-SG14#150: I think anyone who relies on this behavior is probably doing so unintentionally (and their code is probably wrong). Therefore, maybe we should change our SFINAE so that `is_convertible<int(*)(), inplace_function<void()>>` would be `false`.
Related to #149.
The above test case currently does not compile. Clang's error message is:
If we fix #149, then we must make a design decision here: should this code compile (as it does with
std::function
), or should it fail to compile (because returning42
from a function with signaturevoid(int)
usually indicates a programming error)? https://quuxplusone.github.io/blog/2019/01/06/hyper-function/ is related.The text was updated successfully, but these errors were encountered: