-
Notifications
You must be signed in to change notification settings - Fork 1.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
<xmemory> Add constexpr to allocator traits #1369
Conversation
As @AdamBucior said, you need to add tests to Also as far as I know this would finish up P0784R7, so we should mark that in |
Not I have a wip branch lying around that essentially sprinkels constexpr all around vector. The problem that we have is that it is not clear currently what to do about |
I'll add test coverage asap. There are two missing changes for P0784R7 to be marked it as finished.
|
I am moving |
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 for your work here! It looks like there are some merge conflicts right now which is preventing the test run from kicking off. I'll take another look once you have a chance to resolve the conflicts and address the review comments!
tests/std/tests/P0784R7_library_support_for_more_constexpr_containers/test.cpp
Show resolved
Hide resolved
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.
There are some correctness concerns regarding the special alignment changes we do
This suggests that there are insufficient tests there.
Also I am surprised that this works for sized deallocation, as that did not compile in ä1407 Cna you double check that these code paths are tested
Finaly, I am quite surprised that non of the libcxx tests are green now. Did you forget to mark them as passing for clang?
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.
I am sorry for bombarding you with comments :(
tests/std/tests/P0784R7_library_support_for_more_constexpr_containers/test.cpp
Show resolved
Hide resolved
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.
Last comment, but after resolving what the maintainers prefer for changing the allocators this looks great
This is Following P0784R7.
Co-authored-by: Adam Bucior <35536269+AdamBucior@users.noreply.github.com>
…stexpr Changes as per the code review
Apply review suggestion Co-authored-by: Adam Bucior <35536269+AdamBucior@users.noreply.github.com>
Tests check if allocation tasks can be completed at compile time.
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.
Just a small nitpick in test.cpp
and a question of consistency given the recent change with feature-test macros 🐱
tests/std/tests/P0784R7_library_support_for_more_constexpr_containers/test.cpp
Outdated
Show resolved
Hide resolved
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.
Awesome, thanks for all of your work and follow up here! This is now ready for final review!
FYI @MichaelRizkalla, I merged your branch with master to resolve the merge conflicts after #1544 was checked in! |
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 looks good! I had a number of comments but they're all straightforward to resolve; in the interests of time I will prepare a commit to address them.
tests/std/tests/P0784R7_library_support_for_more_constexpr_containers/test.cpp
Outdated
Show resolved
Hide resolved
tests/std/tests/P0784R7_library_support_for_more_constexpr_containers/test.cpp
Outdated
Show resolved
Hide resolved
tests/std/tests/P0784R7_library_support_for_more_constexpr_containers/test.cpp
Outdated
Show resolved
Hide resolved
tests/std/tests/P0784R7_library_support_for_more_constexpr_containers/test.cpp
Show resolved
Hide resolved
Alloc<A<int>> alloc{10}; | ||
assert(alloc.id == 10); | ||
|
||
auto result = std::allocator_traits<Alloc<A<int>>>::allocate(alloc, 10); |
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.
Observation, no change requested: For clarity, I recommend using distinct values for distinct purposes in test code. Here, 10
is being used for the allocator's ID, and 10
is also the number of A<int>
elements being allocated. This makes it more difficult to glance at the source code and immediately recognize the meaning of a 10
.
@MichaelRizkalla @mnatsuhara @miscco I believe this is ready to merge, but if you see any issues with the changes I just pushed (particularly the compiler guard changes), we can continue iterating. |
It's merged! This will ship in VS 2019 16.10 Preview 1. Thanks for implementing this C++20 feature, and for enduring our exceptionally lengthy code review process, and congratulations on your first microsoft/STL commit! 🎉 🚀 😸 |
Description
A small update that adds
_CONSTEXPR20_DYNALLOC
to allocator traits member functions to implement constexpr allocators when the compiler defines__cpp_constexpr_dynamic_alloc
.This pull request implements the default allocator changes in P0784R7
except for [allocator.traits.members] construct and destruct Effects.Useful for #37
Checklist
Before submitting a pull request, please ensure that:
Identifiers in product code changes are properly
_Ugly
as perhttps://eel.is/c++draft/lex.name#3.1 or there are no product code changes.
These changes introduce no known ABI breaks (adding members, renaming members, adding virtual functions, changing whether a type is an aggregate or trivially copyable, etc.).
Your changes are written from scratch using only this repository, the C++ Working Draft (including any cited standards), other WG21 papers (excluding reference implementations outside of proposed standard wording), and LWG issues as reference material. If your changes are derived from a project that's already listed in NOTICE.txt, that's fine, but please mention it. If your changes are derived from any other project, you must mention it here, so we can determine whether the license is compatible and what else needs to be done.