-
Notifications
You must be signed in to change notification settings - Fork 11.5k
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
[libc] Add invoke / invoke_result type traits #65750
Conversation
gchatelet
commented
Sep 8, 2023
•
edited
Loading
edited
- [libc] Add is_object #65749
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.
IIUC this comes mostly from existing implementations, but I can't easily wrap my head around this so I htink we should add a few tests for this...
This is not exhaustive for now but it provides a placeholder for `invoke_result` test mentioned in #65750.
07281d7
to
d14a049
Compare
9e96a93
to
6b7212b
Compare
6b7212b
to
61c3889
Compare
auto lambda = [](int) -> double { return 0; }; | ||
EXPECT_TRUE((is_same_v<invoke_result_t<decltype(lambda), int>, double>)); | ||
} | ||
} |
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.
We're missing tests for a functor with overloaded types:
auto lambda = [](auto a) { return a; };
EXPECT_TRUE((is_same_v<invoke_result_t<decltype(lambda), int>, int>));
EXPECT_TRUE((is_same_v<invoke_result_t<decltype(lambda), double>, double>));
maybe also with auto&
and auto&&
.
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.
Thx! This helped me catch a bug where the function return type should be decltype(auto)
instead of auto
for perfect forwarding.
Thx for the thorough review @legrosbuffle, I really appreciate it. |
This is not exhaustive for now but it provides a placeholder for `invoke_result` test mentioned in llvm#65750.