-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Implement P2445R1 forward_like()
#2974
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 15 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
8066e80
Test __cpp_lib_forward_like
frederick-vs-ja 40639c9
Test cases for std::forward_like
frederick-vs-ja 4407f68
Add P2445R1_forward_like to list
frederick-vs-ja a5927c8
Implement P2445R1 forward_like
frederick-vs-ja 52e206c
Move _Can_reference to <utility>
frederick-vs-ja c0cadc9
Fix misreading
frederick-vs-ja 395c76a
Clang-format
frederick-vs-ja caadb27
Why isn't this constant expression?
frederick-vs-ja ea05143
Fixes according to @CaseyCarter's review comments
frederick-vs-ja 0b6ddb6
Address @CaseyCarter's review comments and avoid nested decltype
frederick-vs-ja c4a9298
Adpot @CaseyCarter's test coverage
frederick-vs-ja 23c7d95
Merge branch 'main' into p2445r1
frederick-vs-ja a0aad9b
Swap type aliases to be consistent with the paper
frederick-vs-ja 1c79721
Partially address @strega-nil-ms's review comments
frederick-vs-ja c85fa43
Complete renaming
frederick-vs-ja 448f6fa
Add comment, expand test slightly.
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
| 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 |
59 changes: 59 additions & 0 deletions
59
tests/std/tests/P2445R1_forward_like/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,59 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| #include <type_traits> | ||
| #include <utility> | ||
|
|
||
| using namespace std; | ||
|
|
||
| struct U {}; // class type so const-qualification is not stripped from a prvalue | ||
| using CU = const U; | ||
| using T = int; | ||
| using CT = const T; | ||
|
|
||
| U u{}; | ||
| const U& cu = u; | ||
|
|
||
| static_assert(is_same_v<decltype(forward_like<T>(U{})), U&&>); | ||
| static_assert(is_same_v<decltype(forward_like<T>(CU{})), CU&&>); | ||
| static_assert(is_same_v<decltype(forward_like<T>(u)), U&&>); | ||
| static_assert(is_same_v<decltype(forward_like<T>(cu)), CU&&>); | ||
| static_assert(is_same_v<decltype(forward_like<T>(move(u))), U&&>); | ||
| static_assert(is_same_v<decltype(forward_like<T>(move(cu))), CU&&>); | ||
|
|
||
| static_assert(is_same_v<decltype(forward_like<CT>(U{})), CU&&>); | ||
| static_assert(is_same_v<decltype(forward_like<CT>(CU{})), CU&&>); | ||
| static_assert(is_same_v<decltype(forward_like<CT>(u)), CU&&>); | ||
| static_assert(is_same_v<decltype(forward_like<CT>(cu)), CU&&>); | ||
| static_assert(is_same_v<decltype(forward_like<CT>(move(u))), CU&&>); | ||
| static_assert(is_same_v<decltype(forward_like<CT>(move(cu))), CU&&>); | ||
|
|
||
| static_assert(is_same_v<decltype(forward_like<T&>(U{})), U&>); | ||
| static_assert(is_same_v<decltype(forward_like<T&>(CU{})), CU&>); | ||
| static_assert(is_same_v<decltype(forward_like<T&>(u)), U&>); | ||
| static_assert(is_same_v<decltype(forward_like<T&>(cu)), CU&>); | ||
| static_assert(is_same_v<decltype(forward_like<T&>(move(u))), U&>); | ||
| static_assert(is_same_v<decltype(forward_like<T&>(move(cu))), CU&>); | ||
|
|
||
| static_assert(is_same_v<decltype(forward_like<CT&>(U{})), CU&>); | ||
| static_assert(is_same_v<decltype(forward_like<CT&>(CU{})), CU&>); | ||
| static_assert(is_same_v<decltype(forward_like<CT&>(u)), CU&>); | ||
| static_assert(is_same_v<decltype(forward_like<CT&>(cu)), CU&>); | ||
| static_assert(is_same_v<decltype(forward_like<CT&>(move(u))), CU&>); | ||
| static_assert(is_same_v<decltype(forward_like<CT&>(move(cu))), CU&>); | ||
|
|
||
| static_assert(is_same_v<decltype(forward_like<T&&>(U{})), U&&>); | ||
| static_assert(is_same_v<decltype(forward_like<T&&>(CU{})), CU&&>); | ||
| static_assert(is_same_v<decltype(forward_like<T&&>(u)), U&&>); | ||
| static_assert(is_same_v<decltype(forward_like<T&&>(cu)), CU&&>); | ||
| static_assert(is_same_v<decltype(forward_like<T&&>(move(u))), U&&>); | ||
| static_assert(is_same_v<decltype(forward_like<T&&>(move(cu))), CU&&>); | ||
|
|
||
| static_assert(is_same_v<decltype(forward_like<CT&&>(U{})), CU&&>); | ||
| static_assert(is_same_v<decltype(forward_like<CT&&>(CU{})), CU&&>); | ||
| static_assert(is_same_v<decltype(forward_like<CT&&>(u)), CU&&>); | ||
| static_assert(is_same_v<decltype(forward_like<CT&&>(cu)), CU&&>); | ||
| static_assert(is_same_v<decltype(forward_like<CT&&>(move(u))), CU&&>); | ||
| static_assert(is_same_v<decltype(forward_like<CT&&>(move(cu))), CU&&>); | ||
|
|
||
| int main() {} // COMPILE-ONLY | ||
StephanTLavavej marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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.