Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/enum.hfa

    r85855b0 r07e9df1  
    11#pragma once
    22
    3 #include "iostream.hfa"
    4 
    5 forall(E) trait Bounded {
    6     E lowerBound();
    7     E upperBound();
     3forall( E ) trait Bounded {
     4        E lowerBound();
     5        E upperBound();
    86};
    97
    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);
     8forall( 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 );
    1513};
    1614
    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);
     15forall( E, T ) trait TypedEnum {
     16        T valueE( E e );
     17        char * labelE( E e );
     18        unsigned int posE( E e );
    2319};
    2420
    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 // };
     21forall( 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.