-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Implement constexpr std::vector #1407
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
Merged
Merged
Changes from all commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
b03c708
Prepare the constexpr machinery needed for string and vector
miscco 0d8082a
Properly initialize
miscco a3add31
Merge branch 'master' into constexpr_machinery
miscco 0ca2b48
Use _CONSTEXPR20_CONTAINER
miscco 4135658
Address review comments
miscco 9b9c2bc
Merge branch 'master' into constexpr_machinery
miscco 3000309
Unblock __cpp_lib_constexpr_dynamic_alloc for all compilers that supp…
miscco 593de17
Unskip some tests
miscco 5e56275
Consistently use __cpp_lib_constexpr_dynamic_alloc
miscco ed8c2dc
Properly guard ranges in tests
miscco 5d393af
Disable portions of P0784 test for EDG due to bugs
mnatsuhara b3140a4
Try to apply workaround
miscco d6f948d
[P10042R2] Implement constexpr vector
miscco c369090
Properly unlock everytime
miscco c0d079b
Another forgotten proxy validation
miscco 1c9b289
Negation is hard
miscco 2a0b677
Merge branch 'main' into gh1407
mnatsuhara fd7c402
Disable portions of P1004R2_constexpr_vector test for EDG and C1XX bugs
mnatsuhara 649724f
update test functions with new _CONSTEXPR20_CONTAINER macro
mnatsuhara 6a93a12
#if out appropriate regions of vector bool test for EDG/cl bugs
mnatsuhara 634acd5
add workaround for DevCom-1331017
mnatsuhara 3edeeaa
Missed updating a few comments with bug numbers in vector bool tests
mnatsuhara 5a32d99
address some review comments
mnatsuhara aa3da7b
add more workarounds for VSO-1269037, VSO-1331017
mnatsuhara eaf17a4
xfail/skip libcxx tests triggered by VSO-1275530
mnatsuhara e2d23ea
update transition comments with new bug number
mnatsuhara 06a7772
fix formatting in expected_results/skipped_tests
mnatsuhara ac012b6
add missing test coverage
mnatsuhara e11cd62
Fix regex _Orphan_me* call
mnatsuhara ad545c0
remove defined(_MSVC_INTERNAL_TESTING) until tests are passing intern…
mnatsuhara 25dba61
Fix up tests with recent changes to constexpr containers status, new bug
mnatsuhara 525847c
update #endif comment to match
mnatsuhara 95fc807
Test addition: Feature-test macro.
StephanTLavavej 9351220
<vector> cleanups: Add noexcept consistently, detach comment.
StephanTLavavej 359de1d
<xmemory> cleanups: Remove unnecessary parentheses, add newline.
StephanTLavavej 9ce6e16
<regex>, <xmemory>: Undo incorrect/unnecessary orphaning changes.
StephanTLavavej c8e6341
<vector>: Guard _Check_all_orphaned identically to its usage.
StephanTLavavej 4f334f0
<vector>: hash for vector<bool> can't be constexpr, and doesn't need …
StephanTLavavej c712259
Test cleanup: Drop std qualification.
StephanTLavavej 664957b
Test cleanup: Include headers.
StephanTLavavej 0d7537b
Test cleanup: Remove unnecessary semicolons.
StephanTLavavej 8929334
Test cleanup: Remove constexpr for deleted functions.
StephanTLavavej a3f5a8d
Test cleanup: This test is always C++20.
StephanTLavavej a5e8e46
Test cleanup: Don't need to define op!= in C++20.
StephanTLavavej 8df8d70
Test cleanup: Change 4 to sizeof(int).
StephanTLavavej 102aa91
Test cleanup: Fix comment typos.
StephanTLavavej b967b7d
Test addition: Verify default_constructed.empty().
StephanTLavavej 6e3d24e
Test cleanup: Comment moved-from assumptions.
StephanTLavavej 8d9dd5b
Test addition: Test the less-than etc. operators.
StephanTLavavej da10679
Test cleanup: Remove iterator arrow test for vector<bool>.
StephanTLavavej c06ac4c
Test change: Make soccc_allocator always equal, to meet the allocator…
StephanTLavavej 2a6e8c9
fix silly typo
mnatsuhara 9946f95
Silence Clang warning. MSVC_INTERNAL_TESTING is non-ugly.
StephanTLavavej File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,150 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| #include <algorithm> | ||
| #include <assert.h> | ||
| #include <iterator> | ||
| #include <memory> | ||
| #include <type_traits> | ||
| #include <utility> | ||
|
|
||
| #pragma warning(disable : 4582) // '%s': constructor is not implicitly called | ||
| #pragma warning(disable : 4583) // '%s': destructor is not implicitly called | ||
|
|
||
| using namespace std; | ||
|
|
||
| struct int_wrapper_copy { | ||
| constexpr int_wrapper_copy() = default; | ||
| constexpr int_wrapper_copy(const int v) : _val(v) {} | ||
|
|
||
| constexpr int_wrapper_copy(const int_wrapper_copy& other) : _val(other._val) {} | ||
| constexpr int_wrapper_copy& operator=(const int_wrapper_copy& other) { | ||
| _val = other._val; | ||
| return *this; | ||
| } | ||
|
|
||
| int_wrapper_copy(int_wrapper_copy&&) = delete; | ||
| int_wrapper_copy& operator=(int_wrapper_copy&&) = delete; | ||
|
|
||
| constexpr bool operator==(const int_wrapper_copy&) const = default; | ||
|
|
||
| int _val = 0; | ||
| }; | ||
|
|
||
| struct int_wrapper_move { | ||
| constexpr int_wrapper_move() = default; | ||
| constexpr int_wrapper_move(const int v) : _val(v) {} | ||
|
|
||
| int_wrapper_move(const int_wrapper_move&) = delete; | ||
| int_wrapper_move& operator=(const int_wrapper_move&) = delete; | ||
|
|
||
| constexpr int_wrapper_move(int_wrapper_move&& other) : _val(exchange(other._val, -1)) {} | ||
StephanTLavavej marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| constexpr int_wrapper_move& operator=(int_wrapper_move&& other) { | ||
| _val = exchange(other._val, -1); | ||
| return *this; | ||
| } | ||
|
|
||
| constexpr bool operator==(const int_wrapper_move&) const = default; | ||
|
|
||
| int _val = 0; | ||
| }; | ||
|
|
||
| static constexpr int_wrapper_copy expected_copy[] = {1, 2, 3, 4}; | ||
| static constexpr int_wrapper_move expected_move[] = {1, 2, 3, 4}; | ||
| static constexpr int_wrapper_move expected_after_move[] = {-1, -1, -1, -1}; | ||
|
|
||
| _CONSTEXPR20_DYNALLOC bool test() { | ||
| { // _Copy_unchecked | ||
| int_wrapper_copy input[] = {1, 2, 3, 4}; | ||
| int_wrapper_copy output[4] = {5, 6, 7, 8}; | ||
|
|
||
| const auto result = _Copy_unchecked(begin(input), end(input), begin(output)); | ||
StephanTLavavej marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| static_assert(is_same_v<remove_const_t<decltype(result)>, int_wrapper_copy*>); | ||
StephanTLavavej marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| assert(result == end(output)); | ||
| assert(equal(begin(expected_copy), end(expected_copy), begin(output), end(output))); | ||
| } | ||
|
|
||
| { // _Copy_backward_unchecked | ||
| int_wrapper_copy input[] = {1, 2, 3, 4}; | ||
| int_wrapper_copy output[4] = {5, 6, 7, 8}; | ||
|
|
||
| const auto result = _Copy_backward_unchecked(begin(input), end(input), end(output)); | ||
| static_assert(is_same_v<remove_const_t<decltype(result)>, int_wrapper_copy*>); | ||
| assert(result == begin(output)); | ||
| assert(equal(begin(expected_copy), end(expected_copy), begin(output), end(output))); | ||
| } | ||
|
|
||
| #if defined(__cpp_constexpr_dynamic_alloc) | ||
| { // _Uninitialized_copy_unchecked | ||
| int_wrapper_copy input[] = {1, 2, 3, 4}; | ||
| int_wrapper_copy output[4]; | ||
|
|
||
| const auto result = _Uninitialized_copy_unchecked(begin(input), end(input), begin(output)); | ||
| static_assert(is_same_v<remove_const_t<decltype(result)>, int_wrapper_copy*>); | ||
| assert(result == end(output)); | ||
| assert(equal(begin(expected_copy), end(expected_copy), begin(output), end(output))); | ||
| } | ||
| #endif // defined(__cpp_constexpr_dynamic_alloc) | ||
|
|
||
| { // _Move_unchecked | ||
| int_wrapper_move input[] = {1, 2, 3, 4}; | ||
| int_wrapper_move output[4] = {5, 6, 7, 8}; | ||
|
|
||
| const auto result = _Move_unchecked(begin(input), end(input), begin(output)); | ||
| static_assert(is_same_v<remove_const_t<decltype(result)>, int_wrapper_move*>); | ||
| assert(result == end(output)); | ||
| assert(equal(begin(expected_move), end(expected_move), begin(output), end(output))); | ||
| if (is_constant_evaluated()) { | ||
| assert(equal(begin(input), end(input), begin(expected_after_move), end(expected_after_move))); | ||
| } | ||
| } | ||
|
|
||
| { // _Move_backward_unchecked | ||
| int_wrapper_move input[] = {1, 2, 3, 4}; | ||
| int_wrapper_move output[4] = {5, 6, 7, 8}; | ||
|
|
||
| const auto result = _Move_backward_unchecked(begin(input), end(input), end(output)); | ||
| static_assert(is_same_v<remove_const_t<decltype(result)>, int_wrapper_move*>); | ||
| assert(result == begin(output)); | ||
| assert(equal(begin(expected_move), end(expected_move), begin(output), end(output))); | ||
| if (is_constant_evaluated()) { | ||
| assert(equal(begin(input), end(input), begin(expected_after_move), end(expected_after_move))); | ||
| } | ||
| } | ||
|
|
||
| #ifdef __cpp_lib_concepts | ||
| { // _Move_backward_common | ||
| int_wrapper_move input[] = {1, 2, 3, 4}; | ||
| int_wrapper_move output[4] = {5, 6, 7, 8}; | ||
|
|
||
| const auto result = ranges::_Move_backward_common(begin(input), end(input), end(output)); | ||
| static_assert(is_same_v<remove_const_t<decltype(result)>, int_wrapper_move*>); | ||
| assert(result == begin(output)); | ||
| assert(equal(begin(expected_move), end(expected_move), begin(output), end(output))); | ||
| if (is_constant_evaluated()) { | ||
| assert(equal(begin(input), end(input), begin(expected_after_move), end(expected_after_move))); | ||
| } | ||
| } | ||
| #endif // __cpp_lib_concepts | ||
|
|
||
| #if defined(__cpp_constexpr_dynamic_alloc) && (defined(__clang__) || defined(__EDG__)) // TRANSITION, DevCom-1333853 | ||
| { // _Uninitialized_move_unchecked | ||
| int_wrapper_move input[] = {1, 2, 3, 4}; | ||
| int_wrapper_move output[4]; | ||
|
|
||
| const auto result = _Uninitialized_move_unchecked(begin(input), end(input), begin(output)); | ||
| static_assert(is_same_v<remove_const_t<decltype(result)>, int_wrapper_move*>); | ||
| assert(result == end(output)); | ||
| assert(equal(begin(expected_move), end(expected_move), begin(output), end(output))); | ||
| if (is_constant_evaluated()) { | ||
| assert(equal(begin(input), end(input), begin(expected_after_move), end(expected_after_move))); | ||
| } | ||
| } | ||
| #endif // defined(__cpp_constexpr_dynamic_alloc) && (defined(__clang__) || defined(__EDG__)) | ||
| return true; | ||
| } | ||
|
|
||
| int main() { | ||
| test(); | ||
| static_assert(test()); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.