-
Notifications
You must be signed in to change notification settings - Fork 1.6k
P2404R3: Move-Only Types For Comparison Concepts #3345
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
7 commits
Select commit
Hold shift + click to select a range
bbdf2f4
Implement P2404R3
JMazurkiewicz 02ed7c6
Skip unsupported libc++ tests
JMazurkiewicz 57b1315
Fix `[diff.cpp20.concepts]` check
JMazurkiewicz b4c1142
Add extra comments
JMazurkiewicz 0d00714
Fix paper citation for feature-test macro.
StephanTLavavej e2a2180
HEADERS FOR THE HEADER THRONE!
StephanTLavavej 4d2318d
A parameter has no name.
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
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
4 changes: 4 additions & 0 deletions
4
tests/std/tests/P2404R3_move_only_types_for_comparison_concepts/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 ..\concepts_latest_matrix.lst |
55 changes: 55 additions & 0 deletions
55
tests/std/tests/P2404R3_move_only_types_for_comparison_concepts/test.compile.pass.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,55 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
#include <compare> | ||
#include <concepts> | ||
#include <cstddef> | ||
#include <memory> | ||
#include <type_traits> | ||
|
||
using namespace std; | ||
|
||
struct MoveOnly { | ||
MoveOnly(int); // not defined | ||
MoveOnly(const MoveOnly&) = delete; | ||
MoveOnly& operator=(const MoveOnly&) = delete; | ||
MoveOnly(MoveOnly&&) = default; | ||
MoveOnly& operator=(MoveOnly&&) = default; | ||
|
||
strong_ordering operator<=>(const MoveOnly&) const = default; | ||
strong_ordering operator<=>(int) const; // not defined | ||
}; | ||
|
||
// Check three_way_comparable_with | ||
static_assert(three_way_comparable_with<MoveOnly, int>); | ||
static_assert(three_way_comparable_with<int, MoveOnly>); | ||
static_assert(three_way_comparable_with<MoveOnly, int, strong_ordering>); | ||
static_assert(three_way_comparable_with<int, MoveOnly, strong_ordering>); | ||
|
||
// Check equality_comparable_with | ||
static_assert(equality_comparable_with<MoveOnly, int>); | ||
static_assert(equality_comparable_with<int, MoveOnly>); | ||
static_assert(equality_comparable_with<unique_ptr<int>, nullptr_t>); | ||
StephanTLavavej marked this conversation as resolved.
Show resolved
Hide resolved
|
||
static_assert(equality_comparable_with<nullptr_t, unique_ptr<int>>); | ||
|
||
// Check totally_ordered_with | ||
static_assert(totally_ordered_with<MoveOnly, int>); | ||
static_assert(totally_ordered_with<int, MoveOnly>); | ||
|
||
// Check [diff.cpp20.concepts] | ||
// clang-format off | ||
template <class T, class U> | ||
requires equality_comparable_with<T, U> | ||
bool attempted_equals(const T&, const U&); // not defined | ||
|
||
template <class T, class U> | ||
requires common_reference_with<const remove_reference_t<T>&, const remove_reference_t<U>&> | ||
StephanTLavavej marked this conversation as resolved.
Show resolved
Hide resolved
|
||
bool attempted_equals(const T&, const U&); // not defined | ||
// clang-format on | ||
|
||
template <class T> | ||
constexpr bool check_diff_cpp20_concepts = !requires(T p) { attempted_equals(p, nullptr); }; | ||
|
||
static_assert(check_diff_cpp20_concepts<shared_ptr<int>>); | ||
|
||
int main() {} // COMPILE-ONLY |
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.