ADTast-experimental
Last change
on this file since c8238c0 was
8bf9448,
checked in by Peter A. Buhr <pabuhr@…>, 3 years ago
|
update existing counter test to use new +=/-= prototype
|
-
Property mode set to
100644
|
File size:
935 bytes
|
Line | |
---|
1 | // |
---|
2 | // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo |
---|
3 | // |
---|
4 | // The contents of this file are covered under the licence agreement in the |
---|
5 | // file "LICENCE" distributed with Cforall. |
---|
6 | // |
---|
7 | // counter.cfa -- |
---|
8 | // |
---|
9 | // Author : Aaron B. Moss |
---|
10 | // Created On : Thu Feb 22 15:27:00 2018 |
---|
11 | // Last Modified By : Peter A. Buhr |
---|
12 | // Last Modified On : Tue Jul 20 21:25:30 2021 |
---|
13 | // Update Count : 4 |
---|
14 | // |
---|
15 | |
---|
16 | #include <fstream.hfa> |
---|
17 | |
---|
18 | // Tests unified increment/decrement builtin functions. |
---|
19 | // Could be extended for other arithmetic unifications |
---|
20 | |
---|
21 | struct counter { int x; }; |
---|
22 | |
---|
23 | counter ?+=?( counter & c, one_t ) { ++c.x; return c; } |
---|
24 | counter ?-=?( counter & c, one_t ) { --c.x; return c; } |
---|
25 | |
---|
26 | int main() { |
---|
27 | counter c = { 42 }; |
---|
28 | c += 1; |
---|
29 | ++c; |
---|
30 | c++; |
---|
31 | sout | "inc" | c.x; |
---|
32 | c -= 1; |
---|
33 | --c; |
---|
34 | c--; |
---|
35 | sout | "dec" | c.x; |
---|
36 | } |
---|
37 | |
---|
38 | // Local Variables: // |
---|
39 | // tab-width: 4 // |
---|
40 | // compile-command: "cfa counter.cfa" // |
---|
41 | // End: // |
---|
Note: See
TracBrowser
for help on using the repository browser.