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

Implement Smart Pointer Creation With Default Initialization #1315

Merged
merged 25 commits into from
Oct 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b2dc09e
Implement P1020R1 and P1973R1
AdamBucior Sep 24, 2020
bbb74d7
Unused template parameter pack
AdamBucior Sep 24, 2020
8e417f7
Remove unused alias
AdamBucior Sep 24, 2020
7733d85
Fix test
AdamBucior Sep 24, 2020
bcfba08
signed/unsigned mismatch
AdamBucior Sep 24, 2020
562ae57
unique_ptr's subscript operator wants size_t
AdamBucior Sep 24, 2020
e8122e5
Code review and warning
AdamBucior Sep 24, 2020
d57e8a6
GH-1315 is based on GH-778 by @Weheineman.
ggweinand Sep 24, 2020
520ccf7
Apply suggestions from code review
AdamBucior Oct 9, 2020
6a3b07f
Code review
AdamBucior Oct 9, 2020
5a8ceb8
clang-format (as always)
AdamBucior Oct 9, 2020
615e044
Use _Voidify_iter
AdamBucior Oct 9, 2020
1a19fe0
Fix tests
AdamBucior Oct 9, 2020
3ab3eeb
clang-format (obviously)
AdamBucior Oct 9, 2020
f19690e
Fix tests
AdamBucior Oct 9, 2020
2b357f0
Rename defaultValue to initializedValue
AdamBucior Oct 10, 2020
8512895
Merge branch 'master' into gh1315
StephanTLavavej Oct 16, 2020
2480d7b
Drop const for value parameters in friend declarations.
StephanTLavavej Oct 16, 2020
c7adba8
Drop unnecessary friendship after refactoring.
StephanTLavavej Oct 16, 2020
90e2ebc
Given `const _Arg&` we don't need `remove_cvref_t`.
StephanTLavavej Oct 16, 2020
cb088ff
Remove leftover comment.
StephanTLavavej Oct 16, 2020
1280bad
Use is_bounded_array_v in make_unique_for_overwrite.
StephanTLavavej Oct 16, 2020
b96db2c
Code review
AdamBucior Oct 16, 2020
0334b43
Correct feature-test macro value is 202002L
CaseyCarter Oct 16, 2020
a7a0693
Improve _Voidify_iter debug codegen.
StephanTLavavej Oct 16, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
270 changes: 200 additions & 70 deletions stl/inc/memory

Large diffs are not rendered by default.

22 changes: 20 additions & 2 deletions stl/inc/xutility
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,29 @@ struct _Get_rebind_alias<_Ty, _Other, void_t<typename _Ty::template rebind<_Othe
using type = typename _Ty::template rebind<_Other>;
};

// FUNCTION TEMPLATE _Voidify_iter
template <class _Iter>
_NODISCARD void* _Voidify_iter(_Iter _It) noexcept {
#if _HAS_IF_CONSTEXPR
if constexpr (is_pointer_v<_Iter>) {
return const_cast<void*>(static_cast<const volatile void*>(_It));
} else
#endif // _HAS_IF_CONSTEXPR
{
return const_cast<void*>(static_cast<const volatile void*>(_STD addressof(*_It)));
}
}

// FUNCTION TEMPLATE _Construct_in_place
template <class _Ty, class... _Types>
void _Construct_in_place(_Ty& _Obj, _Types&&... _Args) noexcept(is_nothrow_constructible_v<_Ty, _Types...>) {
::new (const_cast<void*>(static_cast<const volatile void*>(_STD addressof(_Obj))))
_Ty(_STD forward<_Types>(_Args)...);
::new (_Voidify_iter(_STD addressof(_Obj))) _Ty(_STD forward<_Types>(_Args)...);
}

// FUNCTION TEMPLATE _Default_construct_in_place
template <class _Ty>
void _Default_construct_in_place(_Ty& _Obj) noexcept(is_nothrow_default_constructible_v<_Ty>) {
::new (_Voidify_iter(_STD addressof(_Obj))) _Ty;
}

// STRUCT TEMPLATE pointer_traits
Expand Down
3 changes: 3 additions & 0 deletions stl/inc/yvals_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@
// P1001R2 execution::unseq
// P1006R1 constexpr For pointer_traits<T*>::pointer_to()
// P1007R3 assume_aligned()
// P1020R1 Smart Pointer Creation With Default Initialization
// P1023R0 constexpr For std::array Comparisons
// P1024R3 Enhancing span Usability
// P1032R1 Miscellaneous constexpr
Expand Down Expand Up @@ -219,6 +220,7 @@
// P1959R0 Removing weak_equality And strong_equality
// P1960R0 atomic_ref Cleanup
// P1964R2 Replacing boolean With boolean-testable
// P1973R1 Renaming default_init To for_overwrite
// P1976R2 Explicit Constructors For Fixed-Extent span From Dynamic-Extent Ranges
// P2091R0 Fixing Issues With Range Access CPOs
// P2102R0 Making "Implicit Expression Variations" More Explicit
Expand Down Expand Up @@ -1208,6 +1210,7 @@
#define __cpp_lib_remove_cvref 201711L
#define __cpp_lib_semaphore 201907L
#define __cpp_lib_shift 201806L
#define __cpp_lib_smart_ptr_for_overwrite 202002L
#define __cpp_lib_span 202002L
#define __cpp_lib_ssize 201902L
#define __cpp_lib_starts_ends_with 201711L
Expand Down
1 change: 1 addition & 0 deletions tests/std/test.lst
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ tests\P0912R5_coroutine
tests\P0919R3_heterogeneous_unordered_lookup
tests\P0966R1_string_reserve_should_not_shrink
tests\P1007R3_assume_aligned
tests\P1020R1_smart_pointer_for_overwrite
tests\P1023R0_constexpr_for_array_comparisons
tests\P1032R1_miscellaneous_constexpr
tests\P1135R6_atomic_flag_test
Expand Down
4 changes: 4 additions & 0 deletions tests/std/tests/P1020R1_smart_pointer_for_overwrite/env.lst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

RUNALL_INCLUDE ..\usual_latest_matrix.lst
Loading