#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* labelE(E e); unsigned int posE(E e); V valueE(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* labelE(E e); // unsigned int posE(E e); // }; // forall(E, V| CfaEnum(E)) trait TypedEnum { // V valueE(E e); // };