Skip to content
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

Merged
merged 9 commits into from
Sep 18, 2023

Conversation

zetafunction
Copy link
Contributor

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.

Copy link
Member

@EricWF EricWF left a 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.

@philnik777 philnik777 added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Sep 1, 2023
@zetafunction zetafunction requested a review from a team as a code owner September 7, 2023 18:41
@ldionne ldionne self-requested a review September 12, 2023 18:59
Copy link
Member

@ldionne ldionne left a 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 @@
//===----------------------------------------------------------------------===//
Copy link
Member

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.

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);
Copy link
Member

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.

Copy link
Contributor Author

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?

@ldionne
Copy link
Member

ldionne commented Sep 13, 2023

@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.

@ldionne ldionne self-assigned this Sep 13, 2023
@ldionne ldionne merged commit 078651b into llvm:main Sep 18, 2023
ZijunZhaoCCK pushed a commit to ZijunZhaoCCK/llvm-project that referenced this pull request Sep 19, 2023
ldionne added a commit to ldionne/llvm-project that referenced this pull request Sep 27, 2023
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.
ldionne added a commit that referenced this pull request Sep 28, 2023
Even though the underlying issue was fixed in #65177 when we made
std::pointer_traits SFINAE-friendly, it is worth adding a regression
test since it's so easy to do.
legrosbuffle pushed a commit to legrosbuffle/llvm-project that referenced this pull request Sep 29, 2023
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.
zahiraam pushed a commit to tahonermann/llvm-project that referenced this pull request Oct 24, 2023
zahiraam pushed a commit to tahonermann/llvm-project that referenced this pull request Oct 24, 2023
@zetafunction zetafunction deleted the pointer_traits_sfinae branch October 26, 2023 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants