-
Notifications
You must be signed in to change notification settings - Fork 252
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add partial support for variadics (basic cases, only simple fold expr…
…essions)
- Loading branch information
Showing
15 changed files
with
148 additions
and
17 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,17 @@ | ||
|
||
x: <Ts...: type> type = { | ||
tup: std::tuple<Ts...> = (); | ||
} | ||
|
||
make_string: <Args...: type> (forward args...: Args) -> _ = :std::string = args...; | ||
|
||
make: <T, Args...: type> (forward args...: Args) -> _ = :T = args...; | ||
|
||
main: () | ||
= { | ||
a: x<int, long, std::string> = (); | ||
|
||
std::cout << std::string("xyzzy", 3) << "\n"; | ||
std::cout << make_string("plugh", :u8=3) << "\n"; | ||
std::cout << make<std::string>("abracadabra", :u8=3) << "\n"; | ||
} |
3 changes: 3 additions & 0 deletions
3
regression-tests/test-results/clang-12/pure2-variadics.cpp.execution
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,3 @@ | ||
xyz | ||
plu | ||
abr |
Empty file.
3 changes: 3 additions & 0 deletions
3
regression-tests/test-results/gcc-10/pure2-variadics.cpp.execution
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,3 @@ | ||
xyz | ||
plu | ||
abr |
Empty file.
3 changes: 3 additions & 0 deletions
3
regression-tests/test-results/gcc-13/pure2-variadics.cpp.execution
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,3 @@ | ||
xyz | ||
plu | ||
abr |
Empty file.
3 changes: 3 additions & 0 deletions
3
regression-tests/test-results/msvc-2022/pure2-variadics.cpp.execution
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,3 @@ | ||
xyz | ||
plu | ||
abr |
1 change: 1 addition & 0 deletions
1
regression-tests/test-results/msvc-2022/pure2-variadics.cpp.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 @@ | ||
pure2-variadics.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,50 @@ | ||
|
||
#define CPP2_USE_MODULES Yes | ||
|
||
//=== Cpp2 type declarations ==================================================== | ||
|
||
|
||
#include "cpp2util.h" | ||
|
||
|
||
#line 2 "pure2-variadics.cpp2" | ||
template<typename ...Ts> class x; | ||
|
||
|
||
//=== Cpp2 type definitions and function declarations =========================== | ||
|
||
|
||
#line 2 "pure2-variadics.cpp2" | ||
template<typename ...Ts> class x { | ||
private: std::tuple<Ts...> tup {}; | ||
public: x() = default; | ||
public: x(x const&) = delete; /* No 'that' constructor, suppress copy */ | ||
public: auto operator=(x const&) -> void = delete; | ||
|
||
#line 4 "pure2-variadics.cpp2" | ||
}; | ||
|
||
template<typename ...Args> [[nodiscard]] auto make_string(Args&& ...args) -> auto; | ||
|
||
template<typename T, typename ...Args> [[nodiscard]] auto make(Args&& ...args) -> auto; | ||
|
||
auto main() -> int; | ||
|
||
|
||
//=== Cpp2 function definitions ================================================= | ||
|
||
|
||
#line 6 "pure2-variadics.cpp2" | ||
template<typename ...Args> [[nodiscard]] auto make_string(Args&& ...args) -> auto { return std::string{CPP2_FORWARD(args)...}; } | ||
|
||
template<typename T, typename ...Args> [[nodiscard]] auto make(Args&& ...args) -> auto { return T{CPP2_FORWARD(args)...}; } | ||
|
||
auto main() -> int | ||
{ | ||
x<int,long,std::string> a {}; | ||
|
||
std::cout << std::string("xyzzy", 3) << "\n"; | ||
std::cout << make_string("plugh", cpp2::u8{3}) << "\n"; | ||
std::cout << make<std::string>("abracadabra", cpp2::u8{3}) << "\n"; | ||
} | ||
|
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.cpp2... ok (all Cpp2, passes safety checks) | ||
|
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
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 |
---|---|---|
@@ -1 +1 @@ | ||
"8911:1701" | ||
"8912:1051" |
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
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