-
Notifications
You must be signed in to change notification settings - Fork 1.6k
<tuple>: Make std::make_from_tuple SFINAE friendly
#4528
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
StephanTLavavej
merged 28 commits into
microsoft:main
from
yronglin:improve_make_from_tuple
Mar 28, 2024
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
3416105
<tuple>: Make std::make_from_tuple and std::_Make_from_tuple_impl SFI…
yronglin 731c998
Format
yronglin 959808d
Format
yronglin e41ba98
Revert incorrect change
yronglin 2133da6
<tuple>: Address review comments and add more test
yronglin 1276f61
Format
yronglin 83347f0
Address review comments and format
yronglin 13a6ab6
Add new test to tests/std/test.lst.
StephanTLavavej f7ff18c
Mention libc++'s test files.
StephanTLavavej ab8644f
Add `std::` qualification to `<cstdint>` types.
StephanTLavavej 3073394
Style: Use empty braces for `std::uint8_t{}` temporaries.
StephanTLavavej ab20411
Directly construct `make_index_sequence<MEOW>{}`, no need for `declval`.
StephanTLavavej 26ef5d2
Rename `_Ugly` identifiers: `_Ty` => `T`
StephanTLavavej d65d9e6
Rename `_Ugly` identifiers: `_Tuple` => `Tuple`
StephanTLavavej 7c99e8b
Rename `_Ugly` identifiers: `_Indices` => `Indices`
StephanTLavavej a5b121a
Rename `_Ugly` identifiers: `_Seq` => `Seq`
StephanTLavavej fd217a5
Nitpick: `struct` inheritance is already `public` by default.
StephanTLavavej 1d9bdad
Avoid potentially-confusing `&&` in comments.
StephanTLavavej 48f81d6
Fix comment typo (extra underscore).
StephanTLavavej 9146dfb
`B` and `C` were unused.
StephanTLavavej 920c5d6
Drop old-style (function-based) SFINAE test coverage.
StephanTLavavej 37b1319
No longer need `<cstdint>` and "partial specialization" comments.
StephanTLavavej 55bd07c
`class Seq` and `size_t... Indices` were unused.
StephanTLavavej 60c6564
Restructure `make_from_tuple` into 23/20/17 cases.
StephanTLavavej ba03dc9
Use a default template argument for `_Make_from_tuple_impl`, instead …
StephanTLavavej b5b95a7
Restructure `_Make_from_tuple_impl` into 23/20/17 cases.
StephanTLavavej 4e20186
Drop ALL constraints on `_Make_from_tuple_impl`, then drop test cover…
StephanTLavavej d05eddd
Drop `enable_if_t` layer within `_Can_make_from_tuple`.
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
| 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 | ||
|
|
||
StephanTLavavej marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| RUNALL_INCLUDE ..\usual_17_matrix.lst | ||
74 changes: 74 additions & 0 deletions
74
tests/std/tests/LWG3528_make_from_tuple_impl/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,74 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // Copyright (c) Microsoft Corporation. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
StephanTLavavej marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // derived from libc++'s test files: | ||
| // * std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp | ||
|
|
||
| #include <array> | ||
| #include <tuple> | ||
| #include <type_traits> | ||
| #include <utility> | ||
|
|
||
| struct A { | ||
| int a; | ||
| }; | ||
StephanTLavavej marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| enum class D { | ||
| one, | ||
| two, | ||
| }; | ||
|
|
||
| template <class T, class Tuple, class = void> | ||
| inline constexpr bool has_make_from_tuple = false; | ||
|
|
||
| template <class T, class Tuple> | ||
| inline constexpr bool | ||
| has_make_from_tuple<T, Tuple, std::void_t<decltype(std::make_from_tuple<T>(std::declval<Tuple>()))>> = true; | ||
|
|
||
| // Test std::make_from_tuple. | ||
|
|
||
| // reinterpret_cast, std::tuple<T> | ||
| static_assert(!has_make_from_tuple<int*, std::tuple<A*>>); | ||
| static_assert(has_make_from_tuple<A*, std::tuple<A*>>); | ||
|
|
||
| // reinterpret_cast, std::array<T, 1> | ||
| static_assert(!has_make_from_tuple<int*, std::array<A*, 1>>); | ||
| static_assert(has_make_from_tuple<A*, std::array<A*, 1>>); | ||
|
|
||
| // const_cast, std::tuple<T> | ||
| static_assert(!has_make_from_tuple<char*, std::tuple<const char*>>); | ||
| static_assert(!has_make_from_tuple<volatile char*, std::tuple<const volatile char*>>); | ||
| static_assert(has_make_from_tuple<volatile char*, std::tuple<volatile char*>>); | ||
| static_assert(has_make_from_tuple<char*, std::tuple<char*>>); | ||
| static_assert(has_make_from_tuple<const char*, std::tuple<char*>>); | ||
| static_assert(has_make_from_tuple<const volatile char*, std::tuple<volatile char*>>); | ||
|
|
||
| // const_cast, std::array<T, 1> | ||
| static_assert(!has_make_from_tuple<char*, std::array<const char*, 1>>); | ||
| static_assert(!has_make_from_tuple<volatile char*, std::array<const volatile char*, 1>>); | ||
| static_assert(has_make_from_tuple<volatile char*, std::array<volatile char*, 1>>); | ||
| static_assert(has_make_from_tuple<char*, std::array<char*, 1>>); | ||
| static_assert(has_make_from_tuple<const char*, std::array<char*, 1>>); | ||
| static_assert(has_make_from_tuple<const volatile char*, std::array<volatile char*, 1>>); | ||
|
|
||
| // static_cast, std::tuple<T> | ||
| static_assert(!has_make_from_tuple<int, std::tuple<D>>); | ||
| static_assert(!has_make_from_tuple<D, std::tuple<int>>); | ||
| static_assert(has_make_from_tuple<long, std::tuple<int>>); | ||
| static_assert(has_make_from_tuple<double, std::tuple<float>>); | ||
| static_assert(has_make_from_tuple<float, std::tuple<double>>); | ||
|
|
||
| // static_cast, std::array<T, 1> | ||
| static_assert(!has_make_from_tuple<int, std::array<D, 1>>); | ||
| static_assert(!has_make_from_tuple<D, std::array<int, 1>>); | ||
| static_assert(has_make_from_tuple<long, std::array<int, 1>>); | ||
| static_assert(has_make_from_tuple<double, std::array<float, 1>>); | ||
| static_assert(has_make_from_tuple<float, std::array<double, 1>>); | ||
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.