Last change
on this file since fd0a1799 was
fd0a1799,
checked in by Michael Brooks <mlbrooks@…>, 8 days ago
|
Resurrect test of zero_t/one_t and capture present state of ++
|
-
Property mode set to
100644
|
File size:
898 bytes
|
Rev | Line | |
---|
[fd0a1799] | 1 | #include <fstream.hfa> |
---|
| 2 | |
---|
| 3 | void foo(zero_t) |
---|
| 4 | { |
---|
| 5 | sout | "It's a Zero!"; |
---|
| 6 | } |
---|
| 7 | |
---|
| 8 | void foo(one_t) |
---|
| 9 | { |
---|
| 10 | sout | "It's a One!"; |
---|
| 11 | } |
---|
| 12 | |
---|
| 13 | void foo(int) |
---|
| 14 | { |
---|
| 15 | sout | "It's a Number!"; |
---|
| 16 | } |
---|
| 17 | |
---|
| 18 | void testOverloads() |
---|
| 19 | { |
---|
| 20 | foo(0); |
---|
| 21 | foo(1); |
---|
| 22 | foo(2); |
---|
| 23 | } |
---|
| 24 | |
---|
| 25 | struct S { int i, j; }; |
---|
| 26 | void ?{}( S & s, zero_t ) { s.[i,j] = 0; } // constructors |
---|
| 27 | void ?{}( S & s, one_t ) { s.[i,j] = 1; } |
---|
| 28 | S ?=?( S & dst, zero_t ) { dst.[i,j] = 0; return dst; } // assignment |
---|
| 29 | S ?=?( S & dst, one_t ) { dst.[i,j] = 1; return dst; } |
---|
| 30 | S ?+=?( S & s, one_t ) { s.[i,j] += 1; return s; } // increment |
---|
| 31 | S ?-=?( S & s, one_t ) { s.[i,j] -= 1; return s; } |
---|
| 32 | S ++?( S & s ) { s += 1; return s; } |
---|
| 33 | int ?!=?( S s, zero_t ) { return s.i != 0 && s.j != 0; } // comparison |
---|
| 34 | void testInitAssignQueryIncrement() { |
---|
| 35 | S s = 0; |
---|
| 36 | s = 0; |
---|
| 37 | s = 1; |
---|
| 38 | if ( s ) ++s; |
---|
| 39 | sout | s.i | s.j; |
---|
| 40 | } |
---|
| 41 | |
---|
| 42 | int main() { |
---|
| 43 | testOverloads(); |
---|
| 44 | testInitAssignQueryIncrement(); |
---|
| 45 | return 0; |
---|
| 46 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.