Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/enum.hfa

    r07e9df1 r85855b0  
    11#pragma once
    22
    3 forall( E ) trait Bounded {
    4         E lowerBound();
    5         E upperBound();
     3#include "iostream.hfa"
     4
     5forall(E) trait Bounded {
     6    E lowerBound();
     7    E upperBound();
    68};
    79
    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 );
     10forall(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);
    1315};
    1416
    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
     18forall(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);
    1923};
    2024
    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 }
     25forall(ostype & | basic_ostream(ostype), E, V| CfaEnum(E, V))
     26ostype & ?|?(ostype&, E);
     27
     28forall(ostype & | basic_ostream(ostype), E| CfaEnum(E, quasi_void))
     29ostype & ?|?(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.