-
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
make_shared() For Arrays #309
make_shared() For Arrays #309
Conversation
Uses of max (or min) need to be surrounded by parens e.g. Lines 47 to 50 in 1980e1a
|
Thanks for info! I didn't know that. |
If I understand the log correctly clang-format requires me to change |
I think it might be clang-format 9.0.0 not understanding variable templates? |
Yeah it's a bug of clang-format 9.0.0. See https://bugs.llvm.org/show_bug.cgi?id=42404 |
So looks like the suggested workaround is to add extra parenthesis. So do something like:
|
@SuperWig said:
Yep! The reason for this is that Within the STL, we usually use Lines 26 to 38 in 1980e1a
However, we need the extra parens for |
Sorry misclick |
Changelog for the last batch of changes, which were in response to things that I found during my exhaustive review and didn't submit code review comments for: Add Instead of testing Change Rework the optimization metaprogramming in Similarly for In Mark Change pre-existing code for consistency: upgrade Change In In In Change Adjust the metaprogramming in Also, Fix |
* Include <cstdlib> for malloc. * Include <new> for bad_alloc. * Include <string_view>, newly used. * The precise Word Of Power is that `operator new` is "replaced". * Use size_t for vector indices; this respects 64-bit (not that these vectors can be large). Additionally, we conventionally never say `unsigned` - we would say `unsigned int`. * Remove artificial scopes around try/catch - they already introduce scopes, so this was just extra indentation. * Instead of constructing a std::string in a catch block, compare against a string_view literal, avoiding dynamic memory allocation. * Conventionally use preincrement.
* Initialize InitialValue::value instead of reassigning it. * Test `canCreate > 0` instead of directly testing an integer for being nonzero. * assert_shared_use_get() is an observer. * Always use template argument deduction when calling assert_shared_use_get(). * Add many missing calls to assert_shared_use_get(). * Test plain int (and arrays of known/unknown bound) as it's sensitive to the difference between default-init and value-init. The other types tested have constructors. * Iterating through vectors with `int&` was correct, but `const auto&` is more conventional in our tests for pure observation. (This is more important for maps, where getting the element type wrong is a real possibility.)
@Weheineman Changelog for my test changes - they were mechanical changes so I just went and fixed them instead of leaving code review comments.
|
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 believe that this is ready for checkin! 😸
* Reorder friendship to match the Standard's declaration order. * Extract `_Element_size` for simplicity. * Support extended alignment in `_Allocate_flexible_array`. * Add `_Deallocate_flexible_array` to handle extended alignment. * Mark guard constructors as TRANSITION, P1771R1. * Handle non-pointer iterators when calling `destroy_at()`. * Add `static_assert` to array control blocks. * Add `HighlyAligned` test coverage. * Other test improvements.
Thanks for all your changes and review of this PR! I'm really glad that this PR finally got approved (and hopefully merges soon). Thanks again! |
Thanks for this C++20 feature, @AdamBucior! And thanks for the test coverage, @Weheineman! And the extended alignment support, @CaseyCarter! And the integer overflow resistance, @BillyONeal! |
We introduced a couple of unguarded uses in `<memory>` in microsoft#309 "P0674R1 `make_shared` For Arrays". Fixes DevCom-1346191.
We introduced a couple of unguarded uses in `<memory>` in microsoft#309 "P0674R1 `make_shared` For Arrays". Fixes DevCom-1346191. Fixes AB-1283107.
Description
Resolves #33. It's quite basic implementation but it should work. I would be grateful for any tips on how to upgrade it.
Checklist
Be sure you've read README.md and understand the scope of this repo.
If you're unsure about a box, leave it unchecked. A maintainer will help you.
_Ugly
as perhttps://eel.is/c++draft/lex.name#3.1 or there are no product code changes.
verified by an STL maintainer before automated testing is enabled on GitHub,
leave this unchecked for initial submission).
members, adding virtual functions, changing whether a type is an aggregate
or trivially copyable, etc.).
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 they were derived from a project
that's already listed in NOTICE.txt, that's fine, but please mention it.
If they were derived from any other project (including Boost and libc++,
which are not yet listed in NOTICE.txt), you must mention it here,
so we can determine whether the license is compatible and what else needs
to be done.