File tree Expand file tree Collapse file tree 2 files changed +35
-11
lines changed Expand file tree Collapse file tree 2 files changed +35
-11
lines changed Original file line number Diff line number Diff line change 1
- t: @struct <T: type> type = { }
2
- t: @struct <T: type> type < T> type requires true = { }
3
- main: () = { }
1
+ t: @struct <T: type> type = {
2
+ a: i32 = 1;
3
+ }
4
+ t: @struct <T: type> type < T> type requires std::is_void_v < T> = {
5
+ b: i32 = 2;
6
+ }
7
+ v: <T> i32 = 1; // clang-format off
8
+ v: <> type<void> i32 = 2; // clang-format on
9
+ main: () = {
10
+ [[assert Testing: t<i32>().a == 1]]
11
+ [[assert Testing: t<void>().b == 2]]
12
+ [[assert Testing: (v<i32>) == 1]]
13
+ [[assert Testing: (v<void>) == 2]]
14
+ }
Original file line number Diff line number Diff line change 7
7
#include " cpp2util.h"
8
8
9
9
#line 1 "pure2-template-specialization.cpp2"
10
- template <typename T> class t ;
11
-
10
+ template <typename T> class t ;
11
+
12
12
13
13
// === Cpp2 type definitions and function declarations ===========================
14
14
15
15
#line 1 "pure2-template-specialization.cpp2"
16
- template <typename T> class t { };
17
- template <typename T> requires ( true )
18
- class t<T> {};auto main () -> int;
19
-
16
+ template <typename T> class t {
17
+ public: cpp2::i32 a {1 };
18
+ };
19
+ template <typename T> requires ( std::is_void_v<T> )
20
+ class t<T> {public: cpp2::i32 b {2 };
21
+ };
22
+ template <typename T> extern cpp2::i32 v;// clang-format off
23
+ template <> extern cpp2::i32 v<void >;// clang-format on
24
+ auto main () -> int;
25
+
20
26
21
27
// === Cpp2 function definitions =================================================
22
28
23
29
24
- #line 3 "pure2-template-specialization.cpp2"
25
- auto main () -> int {}
30
+ #line 7 "pure2-template-specialization.cpp2"
31
+ template <typename T> cpp2::i32 v {1 };
32
+ template <> cpp2::i32 v<void > {2 };
33
+ auto main () -> int{
34
+ cpp2::Testing.expects (t<cpp2::i32 >().a ==1 , " " );
35
+ cpp2::Testing.expects (t<void >().b ==2 , " " );
36
+ cpp2::Testing.expects ((v<cpp2::i32 >)==1 , " " );
37
+ cpp2::Testing.expects ((v<void >)==2 , " " );
38
+ }
26
39
You can’t perform that action at this time.
0 commit comments