#pragma once #include "iostream.hfa" forall( istype & | istream( istype ), E | CfaEnum( E ) | Serial(E) ) istype & ?|?( istype &, E & ); forall( ostype & | ostream( ostype ), E | CfaEnum( E ) ) { ostype & ?|?( ostype &, E ); OSTYPE_VOID( E ); } static inline forall( E | CfaEnum(E) | Serial(E) ) { int ?==?( E l, E r ) { return posn( l ) == posn( r ); } // relational operators int ?!=?( E l, E r ) { return posn( l ) != posn( r ); } int ??( E l, E r ) { return posn( l ) > posn( r ); } int ?>=?( E l, E r ) { return posn( l ) >= posn( r ); } E ++?( E & l ) { // increment operators int pos = posn(l); l = fromInt_unsafe(pos+1); return l; } E --?( E & l ) { int pos = posn(l); l = fromInt_unsafe(pos-1); return l; } E ?+=? ( E & l, one_t ) { int pos = posn(l); l = fromInt_unsafe(pos+1); return l; } E ?-=? ( E & l, one_t ) { int pos = posn(l); l = fromInt_unsafe(pos-1); return l; } E ?+=? ( E & l, int i ) { int pos = posn(l); l = fromInt_unsafe(pos+i); return l; } E ?-=? ( E & l, int i ) { int pos = posn(l); l = fromInt_unsafe(pos-i); return l; } E ?++( E & l ) { int pos = posn(l); l = fromInt_unsafe(pos+1); return fromInt_unsafe(pos); } E ?--( E & l ) { int pos = posn(l); l = fromInt_unsafe(pos-1); return fromInt_unsafe(pos); } }