Changes in libcfa/src/enum.hfa [85855b0:07e9df1]
- File:
-
- 1 edited
-
libcfa/src/enum.hfa (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/enum.hfa
r85855b0 r07e9df1 1 1 #pragma once 2 2 3 #include "iostream.hfa" 4 5 forall(E) trait Bounded { 6 E lowerBound(); 7 E upperBound(); 3 forall( E ) trait Bounded { 4 E lowerBound(); 5 E upperBound(); 8 6 }; 9 7 10 forall( E | Bounded(E)) trait Serial {11 unsigned fromInstance(E e);12 E fromInt(unsigned i);13 E succ(E e);14 E pred(E e);8 forall( E | Bounded( E ) ) trait Serial { 9 unsigned fromInstance( E e ); 10 E fromInt( unsigned int posn ); 11 E succ( E e ); 12 E pred( E e ); 15 13 }; 16 14 17 // Design one 18 forall(E, V | Serial(E)) trait CfaEnum { 19 char* labelE(E e); 20 unsigned int posE(E e); 21 V valueE(E e); 22 char* type_name(E e); 15 forall( E, T ) trait TypedEnum { 16 T valueE( E e ); 17 char * labelE( E e ); 18 unsigned int posE( E e ); 23 19 }; 24 20 25 forall(ostype & | basic_ostream(ostype), E, V| CfaEnum(E, V)) 26 ostype & ?|?(ostype&, E); 27 28 forall(ostype & | basic_ostream(ostype), E| CfaEnum(E, quasi_void)) 29 ostype & ?|?(ostype&, E); 30 31 // Design two <- should go for this if we have change the cost model 32 // forall(E | Serial(E)) trait CfaEnum { 33 // char* labelE(E e); 34 // unsigned int posE(E e); 35 // }; 36 37 // forall(E, V| CfaEnum(E)) trait TypedEnum { 38 // V valueE(E e); 39 // }; 21 forall( E, T | TypedEnum( E, T ) ) { 22 // comparison 23 int ?==?( E l, E r ); // true if l and r are same enumerators 24 int ?!=?( E l, E r ); // true if l and r are different enumerators 25 int ?!=?( E l, zero_t ); // true if l is not the first enumerator 26 int ?<?( E l, E r ); // true if l is an enuemerator before r 27 int ?<=?( E l, E r ); // true if l before or the same as r 28 int ?>?( E l, E r ); // true if l is an enuemrator after r 29 int ?>=?( E l, E r ); // true if l after or the same as r 30 }
Note:
See TracChangeset
for help on using the changeset viewer.