#pragma once #include "iostream.hfa" forall(E) trait Bounded { E lowerBound(); E upperBound(); }; forall(E | Bounded(E)) trait Serial { unsigned fromInstance(E e); E fromInt(unsigned i); E succ(E e); E pred(E e); }; // Design one forall(E, V | Serial(E)) trait CfaEnum { char * label(E e); unsigned int posn(E e); V value(E e); char * type_name(E e); }; forall(ostype & | basic_ostream(ostype), E, V | CfaEnum(E, V)) ostype & ?|?(ostype&, E); forall(ostype & | basic_ostream(ostype), E| CfaEnum(E, quasi_void)) ostype & ?|?(ostype&, E); // Design two <- should go for this if we have change the cost model // forall(E | Serial(E)) trait CfaEnum { // char * label(E e); // unsigned int posn(E e); // }; // forall(E, V| CfaEnum(E)) trait TypedEnum { // V value(E e); // }; forall(ostype & | basic_ostream(ostype), E, V| CfaEnum(E, V)) { int ?==?(E, E); int ?<=?(E, E); int ?>=?(E, E); int ??(E, E); // E ++?( E & lhs ); // E ?++( E & lhs ); }