-
Notifications
You must be signed in to change notification settings - Fork 12.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++] Implement LWG3545: std::pointer_traits should be SFINAE-friendly. #65177
Conversation
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.
The implementation looks good, but the tests are lacking.
We need to add tests that substitution actually fails without causing a hard compile error.
libcxx/test/std/utilities/memory/pointer.conversion/to_address.verify.cpp
Outdated
Show resolved
Hide resolved
libcxx/test/std/utilities/memory/pointer.conversion/to_address_without_pointer_traits.pass.cpp
Show resolved
Hide resolved
b6b1d69
to
0778e3e
Compare
…ndly. See https://wg21.link/LWG3545 for background and details. Differential Revision: https://reviews.llvm.org/D158922
0778e3e
to
a47d0c6
Compare
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.
Thanks! This is looking pretty good but I still have a few comments.
@@ -0,0 +1,176 @@ | |||
//===----------------------------------------------------------------------===// |
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.
These tests look really nice, but we should merge them with the ones in libcxx/test/std/utilities/memory/pointer.traits/*
(for example libcxx/test/std/utilities/memory/pointer.traits/difference_type.pass.cpp
).
I think it might make sense to consolidate them in a single libcxx/test/std/utilities/memory/pointer.traits/types.pass.cpp
.
libcxx/test/std/utilities/memory/pointer.conversion/to_address.verify.cpp
Outdated
Show resolved
Hide resolved
libcxx/test/std/utilities/memory/pointer.conversion/to_address_without_pointer_traits.pass.cpp
Show resolved
Hide resolved
libcxx/test/std/utilities/memory/pointer.conversion/to_address.verify.cpp
Outdated
Show resolved
Hide resolved
The standard doesn't define pointer_traits until C++11, but there are some existing tests that seem to test in C++03 mode... so try to preserve that behavior in the updated tests.
ASSERT_SAME_TYPE(typename std::pointer_traits<Ptr>::rebind<long>::other, long*); | ||
#endif | ||
|
||
assert(HasPointerTo<Ptr>::value); |
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.
The test for pointer_to
shouldn't be in types.compile.pass.cpp
since it's not a compile-time only test.
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.
If I change it to using static_assert (which I did), is it OK to leave it here?
@zetafunction I added some suggestions to try and capture what I want here, feel free to reach out on Discord if you want, sometimes it's easier to transmit the exact intent when chatting live. |
…ndly. (llvm#65177) See https://wg21.link/LWG3545 for background and details. Differential Revision: https://reviews.llvm.org/D158922
Even though the underlying issue was fixed in llvm#65177 when we made std::pointer_traits SFINAE-friendly, it is worth adding a regression test since it's so easy to do.
Even though the underlying issue was fixed in llvm#65177 when we made std::pointer_traits SFINAE-friendly, it is worth adding a regression test since it's so easy to do.
…ndly. (llvm#65177) See https://wg21.link/LWG3545 for background and details. Differential Revision: https://reviews.llvm.org/D158922
…ndly. (llvm#65177) See https://wg21.link/LWG3545 for background and details. Differential Revision: https://reviews.llvm.org/D158922
See https://wg21.link/LWG3545 for background and details.
Differential Revision: https://reviews.llvm.org/D158922
One question I have is if this needs to be limited to C++23 and above. For full disclosure, it would be more useful to me if it were not, and it seems like it'd be OK to allow this to leak through to previous C++ versions, since those programs wouldn't have compiled anyway.