1 | #pragma once |
---|
2 | |
---|
3 | #include "iostream.hfa" |
---|
4 | |
---|
5 | forall( istype & | istream( istype ), E | CfaEnum( E ) | Serial(E) ) |
---|
6 | istype & ?|?( istype &, E & ); |
---|
7 | |
---|
8 | forall( ostype & | ostream( ostype ), E | CfaEnum( E ) ) { |
---|
9 | ostype & ?|?( ostype &, E ); |
---|
10 | OSTYPE_VOID( E ); |
---|
11 | } |
---|
12 | |
---|
13 | static inline |
---|
14 | forall( E | CfaEnum(E) | Serial(E) ) { |
---|
15 | int ?==?( E l, E r ) { return posn( l ) == posn( r ); } // relational operators |
---|
16 | int ?!=?( E l, E r ) { return posn( l ) != posn( r ); } |
---|
17 | int ?<?( E l, E r ) { return posn( l ) < posn( r ); } |
---|
18 | int ?<=?( E l, E r ) { return posn( l ) <= posn( r ); } |
---|
19 | int ?>?( E l, E r ) { return posn( l ) > posn( r ); } |
---|
20 | int ?>=?( E l, E r ) { return posn( l ) >= posn( r ); } |
---|
21 | |
---|
22 | E ++?( E & l ) { // increment operators |
---|
23 | int pos = posn(l); |
---|
24 | l = fromInt_unsafe(pos+1); |
---|
25 | return l; |
---|
26 | } |
---|
27 | |
---|
28 | E --?( E & l ) { |
---|
29 | int pos = posn(l); |
---|
30 | l = fromInt_unsafe(pos-1); |
---|
31 | return l; |
---|
32 | } |
---|
33 | |
---|
34 | E ?+=? ( E & l, one_t ) { |
---|
35 | int pos = posn(l); |
---|
36 | l = fromInt_unsafe(pos+1); |
---|
37 | return l; |
---|
38 | } |
---|
39 | |
---|
40 | E ?-=? ( E & l, one_t ) { |
---|
41 | int pos = posn(l); |
---|
42 | l = fromInt_unsafe(pos-1); |
---|
43 | return l; |
---|
44 | } |
---|
45 | |
---|
46 | E ?+=? ( E & l, int i ) { |
---|
47 | int pos = posn(l); |
---|
48 | l = fromInt_unsafe(pos+i); |
---|
49 | return l; |
---|
50 | } |
---|
51 | |
---|
52 | E ?-=? ( E & l, int i ) { |
---|
53 | int pos = posn(l); |
---|
54 | l = fromInt_unsafe(pos-i); |
---|
55 | return l; |
---|
56 | } |
---|
57 | |
---|
58 | E ?++( E & l ) { |
---|
59 | int pos = posn(l); |
---|
60 | l = fromInt_unsafe(pos+1); |
---|
61 | return fromInt_unsafe(pos); |
---|
62 | } |
---|
63 | |
---|
64 | E ?--( E & l ) { |
---|
65 | int pos = posn(l); |
---|
66 | l = fromInt_unsafe(pos-1); |
---|
67 | return fromInt_unsafe(pos); |
---|
68 | } |
---|
69 | } |
---|