-
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
Commits on Nov 18, 2019
-
Configuration menu - View commit details
-
Copy full SHA for 3e6a2ff - Browse repository at this point
Copy the full SHA 3e6a2ffView commit details -
Configuration menu - View commit details
-
Copy full SHA for 52de1ba - Browse repository at this point
Copy the full SHA 52de1baView commit details
Commits on Nov 19, 2019
-
Configuration menu - View commit details
-
Copy full SHA for e169d41 - Browse repository at this point
Copy the full SHA e169d41View commit details -
Configuration menu - View commit details
-
Copy full SHA for dad50ea - Browse repository at this point
Copy the full SHA dad50eaView commit details
Commits on Nov 21, 2019
-
Configuration menu - View commit details
-
Copy full SHA for 07aaa50 - Browse repository at this point
Copy the full SHA 07aaa50View commit details -
Configuration menu - View commit details
-
Copy full SHA for ab24fa6 - Browse repository at this point
Copy the full SHA ab24fa6View commit details -
Configuration menu - View commit details
-
Copy full SHA for 38e6b83 - Browse repository at this point
Copy the full SHA 38e6b83View commit details
Commits on Nov 28, 2019
-
Configuration menu - View commit details
-
Copy full SHA for a586cd8 - Browse repository at this point
Copy the full SHA a586cd8View commit details -
Configuration menu - View commit details
-
Copy full SHA for 77db877 - Browse repository at this point
Copy the full SHA 77db877View commit details
Commits on Nov 29, 2019
-
Configuration menu - View commit details
-
Copy full SHA for 5bb85af - Browse repository at this point
Copy the full SHA 5bb85afView commit details -
Configuration menu - View commit details
-
Copy full SHA for 458424c - Browse repository at this point
Copy the full SHA 458424cView commit details -
Configuration menu - View commit details
-
Copy full SHA for d778d04 - Browse repository at this point
Copy the full SHA d778d04View commit details
Commits on Dec 5, 2019
-
Configuration menu - View commit details
-
Copy full SHA for 53f3c4d - Browse repository at this point
Copy the full SHA 53f3c4dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 03bcabb - Browse repository at this point
Copy the full SHA 03bcabbView commit details -
Configuration menu - View commit details
-
Copy full SHA for 11d8d93 - Browse repository at this point
Copy the full SHA 11d8d93View commit details -
Configuration menu - View commit details
-
Copy full SHA for e1fd4a1 - Browse repository at this point
Copy the full SHA e1fd4a1View commit details -
Configuration menu - View commit details
-
Copy full SHA for f929287 - Browse repository at this point
Copy the full SHA f929287View commit details
Commits on Dec 6, 2019
-
Configuration menu - View commit details
-
Copy full SHA for 04d67e6 - Browse repository at this point
Copy the full SHA 04d67e6View commit details
Commits on Dec 12, 2019
-
Configuration menu - View commit details
-
Copy full SHA for 92ef947 - Browse repository at this point
Copy the full SHA 92ef947View commit details -
Configuration menu - View commit details
-
Copy full SHA for 8c98cf2 - Browse repository at this point
Copy the full SHA 8c98cf2View commit details
Commits on Dec 14, 2019
-
Configuration menu - View commit details
-
Copy full SHA for e2ba89b - Browse repository at this point
Copy the full SHA e2ba89bView commit details
Commits on Jan 29, 2020
-
Configuration menu - View commit details
-
Copy full SHA for f64bfb0 - Browse repository at this point
Copy the full SHA f64bfb0View commit details -
Configuration menu - View commit details
-
Copy full SHA for fd8eef9 - Browse repository at this point
Copy the full SHA fd8eef9View commit details -
Configuration menu - View commit details
-
Copy full SHA for d5f0687 - Browse repository at this point
Copy the full SHA d5f0687View commit details
Commits on Feb 3, 2020
-
Configuration menu - View commit details
-
Copy full SHA for e0d0f08 - Browse repository at this point
Copy the full SHA e0d0f08View commit details
Commits on Mar 2, 2020
-
Configuration menu - View commit details
-
Copy full SHA for 1726327 - Browse repository at this point
Copy the full SHA 1726327View commit details
Commits on Mar 3, 2020
-
Configuration menu - View commit details
-
Copy full SHA for 177bfa2 - Browse repository at this point
Copy the full SHA 177bfa2View commit details
Commits on Mar 4, 2020
-
Configuration menu - View commit details
-
Copy full SHA for f0098a5 - Browse repository at this point
Copy the full SHA f0098a5View commit details
Commits on Mar 5, 2020
-
Adjust and test feature-test macros.
Make __cpp_lib_shared_ptr_arrays vary with _HAS_CXX20 instead of __cpp_concepts (as the feature isn't inherently dependent on concepts). Now that more feature-test macros have varying values, extract them to separate preprocessor blocks where the logic is easier to read.
Configuration menu - View commit details
-
Copy full SHA for 6722355 - Browse repository at this point
Copy the full SHA 6722355View commit details -
memory already includes xmemory, which includes xutility, which inclu…
…des utility. Ironically, the STL's product code doesn't follow a coherent philosophy around "include what you use".
Configuration menu - View commit details
-
Copy full SHA for dcf7dbd - Browse repository at this point
Copy the full SHA dcf7dbdView commit details -
Fix test typo affecting coverage.
This was copy-pasted from make_shared, but it meant to test allocate_shared. Clang noticed that `a5` was unused.
Configuration menu - View commit details
-
Copy full SHA for 7ae0911 - Browse repository at this point
Copy the full SHA 7ae0911View commit details
Commits on Mar 6, 2020
-
Replace concepts usage with SFINAE.
This is less elegant, but works for Clang 9 and EDG.
Configuration menu - View commit details
-
Copy full SHA for 272afd6 - Browse repository at this point
Copy the full SHA 272afd6View commit details -
Configuration menu - View commit details
-
Copy full SHA for bdc84c5 - Browse repository at this point
Copy the full SHA bdc84c5View commit details -
Fix sign-conversion warnings in the test.
When constants like `2` are directly passed to functions taking `size_t`, the compiler can see that the value is being preserved, so it doesn't warn. However, when `2` is perfectly forwarded, only the type `int` is forwarded - the constant nature isn't part of the type system. So, the compiler will warn if it sees a forwarded `int` converted to `size_t`. The fix is to use `2u` etc. in the source code. `unsigned int` being converted to `size_t` is known to be value-preserving (for 64-bit `size_t`, it's a widening).
Configuration menu - View commit details
-
Copy full SHA for 17f2ef6 - Browse repository at this point
Copy the full SHA 17f2ef6View commit details -
Silence SAL annotation warning C28251 in the test.
This is necessary whenever we replace `new` in test code.
Configuration menu - View commit details
-
Copy full SHA for 11834ff - Browse repository at this point
Copy the full SHA 11834ffView commit details -
Fix sign-conversion warning, use C++ casts.
First, this was using functional-style C-semantics casts to convert from unsigned to signed. We conventionally avoid all C-semantics casts regardless of style (except `(void)`). Second, this was implicitly converting from signed back to unsigned, emitting warnings for which we attempt to be clean (even though they're off-by-default). Finally, this had unnecessary parentheses in the conditional operator; it's a judgement call, but stylistically we tend to avoid parentheses given these operators.
Configuration menu - View commit details
-
Copy full SHA for c80db82 - Browse repository at this point
Copy the full SHA c80db82View commit details -
FIXME: Silence buffer overrun warning C6386.
This must be properly investigated before merging.
Configuration menu - View commit details
-
Copy full SHA for f762dee - Browse repository at this point
Copy the full SHA f762deeView commit details -
Configuration menu - View commit details
-
Copy full SHA for e076167 - Browse repository at this point
Copy the full SHA e076167View commit details -
Configuration menu - View commit details
-
Copy full SHA for 07b7b16 - Browse repository at this point
Copy the full SHA 07b7b16View commit details
Commits on Mar 8, 2020
-
Configuration menu - View commit details
-
Copy full SHA for 42b09fe - Browse repository at this point
Copy the full SHA 42b09feView commit details
Commits on Mar 11, 2020
-
Configuration menu - View commit details
-
Copy full SHA for dbe217a - Browse repository at this point
Copy the full SHA dbe217aView commit details -
Adjust comments and class/struct.
In new code, we generally prefer to "detach" introductory comments from braces, especially when that reduces wrapping for the comment and the function parameters. Conversely, we generally prefer to attach TRANSITION comments to the affected lines, so we can easily see what needs to be adjusted when the mentioned bug is fixed. `_Uninitialized_rev_destroying_backout_al` is a class that uses private access control. Therefore, its comment should refer to it as a class. Additionally, we generally avoid relying on classes defaulting to private access control; this is one of the relatively few places where we prefer to repeat the default.
Configuration menu - View commit details
-
Copy full SHA for 22b0262 - Browse repository at this point
Copy the full SHA 22b0262View commit details -
Flip the specialization of
_Ref_count_unbounded_array
.This is a stylistic nitpick - when we have a primary template and a specialization, it's slightly more readable for the primary template to be the `true` case. That's because it's the one that mentions `is_trivially_destructible_v` here. (This diff looks messy, but it's purely moving code around.)
Configuration menu - View commit details
-
Copy full SHA for 00454a2 - Browse repository at this point
Copy the full SHA 00454a2View commit details
Commits on Mar 12, 2020
-
Address some code review comments.
Simplify `_Div_ceil`; still need to handle overflow here and elsewhere. Use RAII guards for reverse destruction. (Also use CTAD.) Drop unnecessary `if (_Size > 0)` branching. Comment `_Destroy_in_place(_Storage)` as being intentional. Drop unnecessary `static_cast<size_t>`.
Configuration menu - View commit details
-
Copy full SHA for 68ad0e4 - Browse repository at this point
Copy the full SHA 68ad0e4View commit details
Commits on Mar 13, 2020
-
Configuration menu - View commit details
-
Copy full SHA for 76a8e2c - Browse repository at this point
Copy the full SHA 76a8e2cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 1c9328e - Browse repository at this point
Copy the full SHA 1c9328eView commit details -
_Allocate_flexible_array
refactoring, part 1.This carefully performs multiplication and addition overflow checks, and it avoids the use of `new[]` with aligned_storage_t that was emitting buffer overrun warnings. The new strategy is to give `_Ref_count_unbounded_array` storage for one element, and simply allocate additional space (via plain ::operator new) for additional elements if necessary. We need a bit of extra logic for alignment, performed with bitwise operations here (to avoid dividing and multiplying, even by a constant power of 2). (The concern is that if the refcount control block has an alignment of 8, and the elements have a size like 1, then the overall space requested might be an odd number like 1729, which might cause ::operator new to think that it doesn't need to return 8-aligned storage. By rounding up to the maximum alignment of the control block and the element, we avoid that issue.) This doesn't yet use an RAII guard for ::operator delete, but I plan to do so in the near future. This uses a non-_Ugly typedef element_type in internal code. This is slightly non-conventional, but safe (because it's a Standard typedef in shared_ptr, it can't be macroized). There's some existing precedent for this, and I wanted to reinforce that "this is the usual element_type definition that you've seen elsewhere". Part 2 will extend this to the allocator control blocks.
4Configuration menu - View commit details
-
Copy full SHA for 25d450f - Browse repository at this point
Copy the full SHA 25d450fView commit details
Commits on Mar 17, 2020
-
Configuration menu - View commit details
-
Copy full SHA for 0d8aae3 - Browse repository at this point
Copy the full SHA 0d8aae3View commit details
Commits on Mar 18, 2020
-
Configuration menu - View commit details
-
Copy full SHA for eba51f7 - Browse repository at this point
Copy the full SHA eba51f7View commit details -
Configuration menu - View commit details
-
Copy full SHA for a39cd1e - Browse repository at this point
Copy the full SHA a39cd1eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 719ba7e - Browse repository at this point
Copy the full SHA 719ba7eView commit details
Commits on Mar 19, 2020
-
_Allocate_flexible_array
refactoring, part 2.This extends the refactoring to allocate_shared. It uses a "hybrid" approach, where the control block contains a union of one element (treated as a flexible array), giving the control block proper alignment, but storage for the control block is allocated as a sequence of `aligned_storage_t<_Align, _Align>` elements. This should resolve all overflow issues. Overflow checking is controllable because we don't need it during cleanup. Add comments citing N4849 [class.dtor]/7, explaining why these destructors must be defined with `{}` instead of `= default;`.
Configuration menu - View commit details
-
Copy full SHA for 45742a4 - Browse repository at this point
Copy the full SHA 45742a4View commit details
Commits on Mar 20, 2020
-
Address all remaining code review feedback.
Replace aligned_storage_t with _Alignas_storage_unit. Comment a meow_copy call within a meow_fill function. Use RAII guards for global delete and allocator deallocate. Respect fancy pointers. Use more CTAD.
Configuration menu - View commit details
-
Copy full SHA for 21d9c48 - Browse repository at this point
Copy the full SHA 21d9c48View commit details -
Configuration menu - View commit details
-
Copy full SHA for 7c6b5e4 - Browse repository at this point
Copy the full SHA 7c6b5e4View commit details
Commits on Apr 2, 2020
-
Configuration menu - View commit details
-
Copy full SHA for b7ceade - Browse repository at this point
Copy the full SHA b7ceadeView commit details -
More code review improvements.
Add `noexcept` to internal machinery. Instead of testing `(rank_v<_Ty>) > 0`, simply test `is_array_v<_Ty>`. Change `_Reverse_destroy_multidimensional_n_guard` to be an aggregate. (Note that Clang 10 doesn't support CTAD for aggregates.) Rework the optimization metaprogramming in `_Uninitialized_copy_multidimensional`. First, `_Ptr_copy_cat<_Ty*, _Ty*>::_Really_trivial` was incorrect. This is because `_Ptr_copy_cat` checks `is_trivially_assignable_v`, which will be false when `_Ty` is an array. Instead, we should test `is_trivial_v<_Ty>`. (We don't need the rest of what `_Ptr_copy_cat` does, because we're not working with user-defined iterators, and our source and destination are the same type.) Second, `is_trivial_v<_Ty>` can be the first thing we test; when we're working with trivial elements, we can perform a single `_Copy_memmove`, regardless of whether these are single-dimensional or multi-dimensional arrays. Finally, for `is_array_v<_Ty>`, it was strange (although correct) to construct an RAII guard for each iteration of the loop. We can lift this out and simply update the guard's index. (Same transformation for the following algorithms.) Similarly for `_Uninitialized_value_construct_multidimensional_n`, `_Use_memset_value_construct_v<_Ty*>` was incorrect as it checks `is_scalar` which is false for arrays. We need to use `remove_all_extents_t<_Ty>`, which I've been referring to as `_Item`. Also similarly, we can perform this `_Zero_range` optimization at the top level. Finally, we should consistently use `_Idx` instead of `_Count` to iterate (also changed below). In `_Uninitialized_fill_multidimensional_n`, add the `// intentionally copy, not fill` comment (previously applied to the allocator version). Mark `_Get_ptr()` as `_NODISCARD` and `noexcept`. Change pre-existing code for consistency: upgrade `_Ref_count_obj_alloc2` to `_Ref_count_obj_alloc3`. The difference is that we store _Rebind_alloc_t<_Alloc, _Ty> so we can directly use it later. (We still need to rebind for `_Delete_this`.) Also add a `static_assert` verifying that we're following the Standard's `remove_cv_t` wording. Change `_Reverse_destroy_multidimensional_n_al_guard` and its associated algorithms similarly to the non-allocator versions. In `_Uninitialized_copy_multidimensional_al`, change `_Uses_default_construct<_Alloc, _Ty*, _Ty>` to `_Uses_default_construct<_Alloc, _Item*, const _Item&>`. This is because the provided `_Alloc` is for the `_Item` (aka `remove_all_extents_t<_Ty>`) that we ultimately construct from a const lvalue. In `_Uninitialized_value_construct_multidimensional_n_al`, similarly change the `_Zero_range` metaprogramming. In `_Uninitialized_fill_multidimensional_n_al`, slightly adjust `_Uses_default_construct<_Alloc, _Ty*, _Ty>` to `_Uses_default_construct<_Alloc, _Ty*, const _Ty&>` because we construct from a const lvalue, and that distinction could be important. Change `_Ref_count_unbounded_array_alloc` to store `_Rebind_alloc_t<_Alloc, remove_all_extents_t<_Ty>>` so we don't need to rebind it later. Also `static_assert` `remove_cv_t`. Adjust the metaprogramming in `_Destroy()`. `is_trivially_destructible<_Element_type>` was correct (`_Element_type` removes the unbounded array, and the type trait "recurses" to the non-array item), but `is_trivially_destructible<_Item>` is what we're ultimately interested in, and will be more consistent with other control blocks. Also, `_Rebound` is never a reference now, and we have the `_Item` typedef. Fix `_Ref_count_bounded_array_alloc` comment; "for object" should be "for bounded array". Similarly change its implementation. Here, `is_trivially_destructible<_Ty>` was correct (`_Ty` is a bounded array), but`is_trivially_destructible<_Item>` lets us be consistent with the unbounded array control block.
Configuration menu - View commit details
-
Copy full SHA for c8b6d32 - Browse repository at this point
Copy the full SHA c8b6d32View commit details
Commits on Apr 7, 2020
-
Configuration menu - View commit details
-
Copy full SHA for 9959d21 - Browse repository at this point
Copy the full SHA 9959d21View commit details -
Configuration menu - View commit details
-
Copy full SHA for 731ab48 - Browse repository at this point
Copy the full SHA 731ab48View commit details -
Configuration menu - View commit details
-
Copy full SHA for d017e0a - Browse repository at this point
Copy the full SHA d017e0aView commit details -
* 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.
Configuration menu - View commit details
-
Copy full SHA for 5b4eb44 - Browse repository at this point
Copy the full SHA 5b4eb44View commit details -
* 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.)
Configuration menu - View commit details
-
Copy full SHA for 0c0cb15 - Browse repository at this point
Copy the full SHA 0c0cb15View commit details
Commits on Apr 8, 2020
-
* 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.
Configuration menu - View commit details
-
Copy full SHA for e7daab4 - Browse repository at this point
Copy the full SHA e7daab4View commit details