-
Notifications
You must be signed in to change notification settings - Fork 1.6k
constexpr for std::array Comparisons #599
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
ggweinand
merged 18 commits into
microsoft:master
from
ggweinand:constexprForArrayComparisons
Mar 31, 2020
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
de0d63c
Add constexpr to array comparison functions + change feature test macro.
ggweinand e8ba3a5
Fixed clang-format on array and moved comment in yvals_core.h
ggweinand 9acc937
Corrected feature test macro constant
ggweinand 9d1e8af
Removed libcxx test skip
ggweinand 63567cb
Added constexpr testing for array comparison operators
ggweinand 3dd6447
clang-formatted the test file
ggweinand bd1e522
Added CXX20 feature test macro
ggweinand fe3ca57
Fixed 0 size array initialization in test file.
ggweinand 41b2630
Test variables made global and const, removed to_array, fix typo
ggweinand 942a458
clang-format test file
ggweinand 9c465b6
Fixed typo, duplicate line and alignment in the constexpr operator test.
ggweinand cae9bcf
clang-format array
ggweinand 20dd815
Changed const global variables to constexpr in test file.
ggweinand 98d103a
Removed double parenthesis in test file.
ggweinand c187f72
Update tests/std/tests/P1023R0_constexpr_for_array_comparisons/test.cpp
ggweinand 77cd4b7
STL's suggestion to avoid disabling clang-format and shorten test.
ggweinand 88ae93b
clang-format 10 array
ggweinand 0e921d7
Removed test skip from expected_results.txt to match skipped_tests.txt
ggweinand 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
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
4 changes: 4 additions & 0 deletions
4
tests/std/tests/P1023R0_constexpr_for_array_comparisons/env.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,4 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| RUNALL_INCLUDE ..\usual_latest_matrix.lst |
71 changes: 71 additions & 0 deletions
71
tests/std/tests/P1023R0_constexpr_for_array_comparisons/test.cpp
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,71 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| #include <array> | ||
| #include <cassert> | ||
|
|
||
| using namespace std; | ||
|
|
||
| constexpr array<int, 5> a0{{2, 8, 9, 1, 9}}; | ||
| constexpr array<int, 3> a1{{2, 8, 9}}; | ||
| constexpr array<int, 5> a2{{2, 8, 9, 1, 8}}; | ||
| constexpr array<int, 0> a3{}; | ||
|
|
||
| constexpr void test_operator_eq() { | ||
| assert(a0 == a0); | ||
| assert(a1 == a1); | ||
| assert(!(a0 == a2)); | ||
| assert(a3 == a3); | ||
| } | ||
|
|
||
| constexpr void test_operator_neq() { | ||
| assert(!(a0 != a0)); | ||
| assert(!(a1 != a1)); | ||
| assert(a0 != a2); | ||
| assert(!(a3 != a3)); | ||
| } | ||
|
|
||
| constexpr void test_operator_lt() { | ||
| assert(!(a0 < a0)); | ||
| assert(!(a1 < a1)); | ||
| assert(a2 < a0); | ||
| assert(!(a3 < a3)); | ||
| } | ||
|
|
||
| constexpr void test_operator_gt() { | ||
| assert(!(a0 > a0)); | ||
| assert(!(a1 > a1)); | ||
| assert(a0 > a2); | ||
| assert(!(a3 > a3)); | ||
| } | ||
|
|
||
|
|
||
| constexpr void test_operator_leq() { | ||
| assert(a0 <= a0); | ||
CaseyCarter marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| assert(a1 <= a1); | ||
| assert(a2 <= a0); | ||
| assert(a3 <= a3); | ||
| } | ||
|
|
||
|
|
||
| constexpr void test_operator_geq() { | ||
| assert(a0 >= a0); | ||
| assert(a1 >= a1); | ||
| assert(a0 >= a2); | ||
| assert(a3 >= a3); | ||
| } | ||
|
|
||
| constexpr bool test() { | ||
| test_operator_eq(); | ||
| test_operator_neq(); | ||
| test_operator_lt(); | ||
| test_operator_gt(); | ||
| test_operator_leq(); | ||
| test_operator_geq(); | ||
| return true; | ||
| } | ||
|
|
||
| int main() { | ||
| test(); | ||
StephanTLavavej marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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
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.