This patch fixes issue 2574.
Details
Diff Detail
Event Timeline
test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp | ||
---|---|---|
128 | Is it okay to allow assignment of functions with return types that are convertible to each other? The issue says:
|
Thanks for working on this.
include/functional | ||
---|---|---|
2189 | Here. | |
2231 | I think this should just be _EnableIfCallable<typename decay<_Fp>::type>, since we already add the reference inside __callable above. Alternatively, I think it would be even better to NOT add the reference inside __callable, and instead do it when we call _EnableIfCallable. | |
test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp | ||
128 | Callable seems to allow implicit conversions to the return type, so I think that's OK. However, A is not convertible to int (or vice-versa), so I think your test is correct as-is. You could also test that a F1 can't be assigned to a F2. |
include/functional | ||
---|---|---|
2231 | Good catch. I will remove the reference here. If you think it would be better, I can make another patch to update all instances of _EnableIfCallable. |
include/functional | ||
---|---|---|
2231 | I would update this patch as suggested. |
include/functional | ||
---|---|---|
2231 | Do you want me to update all three times _EnableIfCallable is used, in this patch (that's fine, just checking)? |
LGTM. It would be great if you could provide a patch that moves adding the reference outside of __callable, such that the code becomes: _EnableIfCallable<typename decay<_Fp>::type&> (notice the added reference here). You'd have to look at other usages of _EnableIfCallable too. Note that some usages of _EnableIfCallable correspond to places in the Standard where the term Lvalue-Callable is used. We could consider adding a LValueCallable trait to mirror that. Just a suggestion.
It would be great if you could provide a patch that moves adding the reference outside of __callable.
Sounds good. Will do.
Here.