|
Last change
on this file since c40a982 was 64eeb06, checked in by Peter A. Buhr <pabuhr@…>, 18 months ago |
|
change basic_ostream to ostream, first attempt of enumeration input
|
-
Property mode
set to
100644
|
|
File size:
1.2 KB
|
| Line | |
|---|
| 1 | #pragma once
|
|---|
| 2 |
|
|---|
| 3 | #include "iostream.hfa"
|
|---|
| 4 |
|
|---|
| 5 | forall( E ) trait Bounded {
|
|---|
| 6 | E lowerBound();
|
|---|
| 7 | E upperBound();
|
|---|
| 8 | };
|
|---|
| 9 |
|
|---|
| 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 );
|
|---|
| 15 | };
|
|---|
| 16 |
|
|---|
| 17 | // Design one
|
|---|
| 18 | forall( E, V | Serial( E ) ) trait CfaEnum {
|
|---|
| 19 | char * label( E e );
|
|---|
| 20 | unsigned int posn( E e );
|
|---|
| 21 | V value( E e );
|
|---|
| 22 | };
|
|---|
| 23 |
|
|---|
| 24 | // I/O
|
|---|
| 25 |
|
|---|
| 26 | forall( istype & | istream( istype ), E, V | CfaEnum( E, V ) )
|
|---|
| 27 | istype & ?|?( istype &, E );
|
|---|
| 28 |
|
|---|
| 29 | forall( ostype & | ostream( ostype ), E, V | CfaEnum( E, V ) ) {
|
|---|
| 30 | ostype & ?|?( ostype &, E );
|
|---|
| 31 | OSTYPE_VOID( E );
|
|---|
| 32 | }
|
|---|
| 33 |
|
|---|
| 34 | forall( ostype & | ostream( ostype ), E | CfaEnum( E, quasi_void ) ) {
|
|---|
| 35 | ostype & ?|?( ostype &, E );
|
|---|
| 36 | OSTYPE_VOID( E );
|
|---|
| 37 | }
|
|---|
| 38 |
|
|---|
| 39 | // Design two <- should go for this if we have change the cost model
|
|---|
| 40 | // forall( E | Serial( E ) ) trait CfaEnum {
|
|---|
| 41 | // char * label( E e );
|
|---|
| 42 | // unsigned int posn( E e );
|
|---|
| 43 | // };
|
|---|
| 44 |
|
|---|
| 45 | // forall( E, V| CfaEnum( E)) trait TypedEnum {
|
|---|
| 46 | // V value( E e);
|
|---|
| 47 | // };
|
|---|
| 48 |
|
|---|
| 49 | forall( E, V | CfaEnum( E, V ) ) { // relational operators
|
|---|
| 50 | int ?==?( E, E );
|
|---|
| 51 | int ?!=?( E, E );
|
|---|
| 52 | int ?<?( E, E );
|
|---|
| 53 | int ?<=?( E, E );
|
|---|
| 54 | int ?>?( E, E );
|
|---|
| 55 | int ?>=?( E, E );
|
|---|
| 56 |
|
|---|
| 57 | int ++?( E &);
|
|---|
| 58 | int ?++( E &);
|
|---|
| 59 | int --?( E &);
|
|---|
| 60 | int ?--( E &);
|
|---|
| 61 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.