File tree Expand file tree Collapse file tree 2 files changed +23
-5
lines changed Expand file tree Collapse file tree 2 files changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,13 @@ quantity: type = {
4
4
number = x;
5
5
_ = _;
6
6
}
7
+ operator+=: (inout this, that) -> forward quantity = {
8
+ _ = number += that.number;
9
+ return this;
10
+ }
7
11
}
8
12
9
- main: () = { _ = :quantity = (std::in_place, 1729); }
13
+ main: () = {
14
+ x: quantity = (std::in_place, 1729);
15
+ _ = x += x;
16
+ }
Original file line number Diff line number Diff line change @@ -17,15 +17,19 @@ class quantity {
17
17
private: cpp2::i32 number;
18
18
public: explicit quantity (cpp2::in<std::in_place_t > _, cpp2::in<cpp2::i32 > x);
19
19
20
+
21
+ #line 7 "pure2-bugfix-for-discard-precedence.cpp2"
22
+ public: [[nodiscard]] auto operator +=(quantity const & that) -> quantity&;
23
+
20
24
public: quantity(quantity const &) = delete ; /* No 'that' constructor, suppress copy */
21
25
public: auto operator =(quantity const &) -> void = delete ;
22
26
23
27
24
- #line 7 "pure2-bugfix-for-discard-precedence.cpp2"
28
+ #line 11 "pure2-bugfix-for-discard-precedence.cpp2"
25
29
};
26
30
27
31
auto main () -> int;
28
-
32
+
29
33
30
34
// === Cpp2 function definitions =================================================
31
35
@@ -38,7 +42,14 @@ auto main() -> int;
38
42
39
43
static_cast <void >(_);
40
44
}
45
+ [[nodiscard]] auto quantity::operator +=(quantity const & that) -> quantity&{
46
+ static_cast <void >(number += that.number );
47
+ return (*this );
48
+ }
41
49
42
- #line 9 "pure2-bugfix-for-discard-precedence.cpp2"
43
- auto main () -> int{static_cast <void >(quantity{std::in_place, 1729 }); }
50
+ #line 13 "pure2-bugfix-for-discard-precedence.cpp2"
51
+ auto main () -> int{
52
+ quantity x {std::in_place, 1729 };
53
+ static_cast <void >(x += std::move (x));
54
+ }
44
55
You can’t perform that action at this time.
0 commit comments