forked from hsutter/cppfront
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test case for C++26 pack indexing
- Loading branch information
Showing
3 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,11 @@ | ||
f0: <T...> () == :T...[0] = 32; | ||
// f1: <T...> () == :T...[0]::value_type = 4; // Pending #533. | ||
// 'V...[0]' needs to be made an _id-expression_. | ||
// f2: <V...: _> () == V...[0]; | ||
// f3: <V...: _> () == V...[0].front(); | ||
main: () = { | ||
static_assert(f0<i64>() == 32); | ||
// static_assert(f1<std::integral_constant<i16, 8>>() == 4); | ||
// static_assert(f2<2>() == 2); | ||
// static_assert(f3<(:std::array = (1))>() == 1); | ||
} |
35 changes: 35 additions & 0 deletions
35
regression-tests/test-results/pure2-variadics-indexing.cpp
This file contains 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,35 @@ | ||
|
||
#define CPP2_IMPORT_STD Yes | ||
|
||
//=== Cpp2 type declarations ==================================================== | ||
|
||
|
||
#include "cpp2util.h" | ||
|
||
#line 1 "pure2-variadics-indexing.cpp2" | ||
|
||
|
||
//=== Cpp2 type definitions and function declarations =========================== | ||
|
||
#line 1 "pure2-variadics-indexing.cpp2" | ||
template<typename ...T> [[nodiscard]] constexpr auto f0() -> decltype(auto); | ||
// f1: <T...> () == :T...[0]::value_type = 4; // Pending #533. | ||
// 'V...[0]' needs to be made an _id-expression_. | ||
// f2: <V...: _> () == V...[0]; | ||
// f3: <V...: _> () == V...[0].front(); | ||
#line 6 "pure2-variadics-indexing.cpp2" | ||
auto main() -> int; | ||
|
||
//=== Cpp2 function definitions ================================================= | ||
|
||
#line 1 "pure2-variadics-indexing.cpp2" | ||
template<typename ...T> [[nodiscard]] constexpr auto f0() -> decltype(auto) { return T...[0]{32}; } | ||
|
||
#line 6 "pure2-variadics-indexing.cpp2" | ||
auto main() -> int{ | ||
static_assert(f0<cpp2::i64>() == 32); | ||
// static_assert(f1<std::integral_constant<i16, 8>>() == 4); | ||
// static_assert(f2<2>() == 2); | ||
// static_assert(f3<(:std::array = (1))>() == 1); | ||
} | ||
|
2 changes: 2 additions & 0 deletions
2
regression-tests/test-results/pure2-variadics-indexing.cpp2.output
This file contains 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,2 @@ | ||
pure2-variadics-indexing.cpp2... ok (all Cpp2, passes safety checks) | ||
|