-
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
Should int(*)()
be convertible to inplace_function<void()>
?
#159
base: master
Are you sure you want to change the base?
Conversation
@Quuxplusone I would personally prefer a fail. I am not a fan of silent issues, and this is clearly a programmer error. However, it may be necessary to conform to One could use |
You can use Ah! But we could just put the conversion under a compile-time flag like [EDIT already: I was missing that it would be difficult to test both behaviors. But that's a minor concern, and I guess the proper place to address it would be in the build matrix, not in the test code.] |
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`.
Put the "standard" behavior under a macro flag, and default to the "safer" behavior. That is, disallow the conversion by default.
Hmm, definitely prefer compile-time flag over warning. Afaik that wouldn't be standardizable in this fashion though.
In light of other design changes wanted for inplace_function, I'd recommend to close this hole early and avoid users becoming reliant on it. Imo the advantages of sticking with the existing std::function design and with that its known problems, like this and #158, do not outweigh the disadvantages.
My vote is for never allowing this conversion.
… On 23. May 2019, at 19:45, Quuxplusone ***@***.***> wrote:
compile-time flag
|
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 #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
.I'm posting this PR to get opinions (e.g. @Voultapher @p-groarke), not necessarily because I think it's the right approach (frankly I don't). Vice versa, if we decide to make
is_convertible<int(*)(), inplace_function<void()>> == false
, then we'll have to bikeshed the right way to do that. Should we eliminate the special cases in ourdetail::is_invocable_r_impl
, and if so, should we rename it so that people don't confuse it with the standardis_invocable_r
?