ADTast-experimentalpthread-emulationqualifiedEnum
Last change
on this file since 1b64344 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
|
Rev | Line | |
---|
[d2887f7] | 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 | // |
---|
[dc8511c] | 7 | // counter.cfa -- |
---|
[d2887f7] | 8 | // |
---|
| 9 | // Author : Aaron B. Moss |
---|
| 10 | // Created On : Thu Feb 22 15:27:00 2018 |
---|
[dc8511c] | 11 | // Last Modified By : Peter A. Buhr |
---|
[8bf9448] | 12 | // Last Modified On : Tue Jul 20 21:25:30 2021 |
---|
| 13 | // Update Count : 4 |
---|
[d2887f7] | 14 | // |
---|
| 15 | |
---|
[8bf9448] | 16 | #include <fstream.hfa> |
---|
| 17 | |
---|
[d2887f7] | 18 | // Tests unified increment/decrement builtin functions. |
---|
| 19 | // Could be extended for other arithmetic unifications |
---|
| 20 | |
---|
| 21 | struct counter { int x; }; |
---|
| 22 | |
---|
[8bf9448] | 23 | counter ?+=?( counter & c, one_t ) { ++c.x; return c; } |
---|
| 24 | counter ?-=?( counter & c, one_t ) { --c.x; return c; } |
---|
[d2887f7] | 25 | |
---|
| 26 | int main() { |
---|
| 27 | counter c = { 42 }; |
---|
| 28 | c += 1; |
---|
| 29 | ++c; |
---|
| 30 | c++; |
---|
[8bf9448] | 31 | sout | "inc" | c.x; |
---|
[d2887f7] | 32 | c -= 1; |
---|
| 33 | --c; |
---|
| 34 | c--; |
---|
[8bf9448] | 35 | sout | "dec" | c.x; |
---|
[d2887f7] | 36 | } |
---|
| 37 | |
---|
| 38 | // Local Variables: // |
---|
| 39 | // tab-width: 4 // |
---|
[dc8511c] | 40 | // compile-command: "cfa counter.cfa" // |
---|
| 41 | // End: // |
---|
Note: See
TracBrowser
for help on using the repository browser.