Changes in libcfa/src/enum.hfa [07e9df1:85855b0]
- File:
-
- 1 edited
-
libcfa/src/enum.hfa (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/enum.hfa
r07e9df1 r85855b0 1 1 #pragma once 2 2 3 forall( E ) trait Bounded { 4 E lowerBound(); 5 E upperBound(); 3 #include "iostream.hfa" 4 5 forall(E) trait Bounded { 6 E lowerBound(); 7 E upperBound(); 6 8 }; 7 9 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);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); 13 15 }; 14 16 15 forall( E, T ) trait TypedEnum { 16 T valueE( E e ); 17 char * labelE( E e ); 18 unsigned int posE( E e ); 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); 19 23 }; 20 24 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 } 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 // };
Note:
See TracChangeset
for help on using the changeset viewer.