-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
Compile the code:
struct s1 { static int f(int) { return 0; } };
struct s2 { int operator()(int) const { return 0; } } S2;
auto l1 = [](int) { return 0; };
std::function sf1 = &s1::f; // works
std::function sf2 = S2; // works
std::function sf3 = l1; // works
std23::function_ref f1 = &s1::f; // works
std23::function_ref f2 = S2; // doesn't work
std23::function_ref f3 = l1; // doesn't workExpected
Successful compilation in all 3 cases, same as std::function above.
Actual
Only the first case works.
2nd:
error: class template argument deduction failed:
error: no matching function for call to 'function_ref(main()::s2&)'
3rd:
error: class template argument deduction failed:
error: no matching function for call to 'function_ref(main()::<lambda(int)>&)'
Compiler Explorer:
https://godbolt.org/z/rsc1ndjoh
Is it by design / overlook? As mentioned, std::function supports all these cases.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels