Changes in libcfa/src/rational.hfa [fd54fef:0087e0e]
- File:
-
- 1 edited
-
libcfa/src/rational.hfa (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/rational.hfa
rfd54fef r0087e0e 20 20 #include "iostream.hfa" 21 21 22 trait scalar( T ) {22 trait scalar( otype T ) { 23 23 }; 24 24 25 trait arithmetic( T | scalar( T ) ) {25 trait arithmetic( otype T | scalar( T ) ) { 26 26 int !?( T ); 27 27 int ?==?( T, T ); … … 46 46 // implementation 47 47 48 forall( RationalImpl | arithmetic( RationalImpl ) ) {48 forall( otype RationalImpl | arithmetic( RationalImpl ) ) { 49 49 struct Rational { 50 50 RationalImpl numerator, denominator; // invariant: denominator > 0 … … 89 89 90 90 // I/O 91 forall( istype &| istream( istype ) | { istype & ?|?( istype &, RationalImpl & ); } )91 forall( dtype istype | istream( istype ) | { istype & ?|?( istype &, RationalImpl & ); } ) 92 92 istype & ?|?( istype &, Rational(RationalImpl) & ); 93 93 94 forall( ostype &| ostream( ostype ) | { ostype & ?|?( ostype &, RationalImpl ); } ) {94 forall( dtype ostype | ostream( ostype ) | { ostype & ?|?( ostype &, RationalImpl ); } ) { 95 95 ostype & ?|?( ostype &, Rational(RationalImpl) ); 96 96 void ?|?( ostype &, Rational(RationalImpl) ); … … 98 98 } // distribution 99 99 100 forall( RationalImpl | arithmetic( RationalImpl ) |{RationalImpl ?\?( RationalImpl, unsigned long );} )100 forall( otype RationalImpl | arithmetic( RationalImpl ) |{RationalImpl ?\?( RationalImpl, unsigned long );} ) 101 101 Rational(RationalImpl) ?\?( Rational(RationalImpl) x, long int y ); 102 102 103 103 // conversion 104 forall( RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl ); } )104 forall( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl ); } ) 105 105 double widen( Rational(RationalImpl) r ); 106 forall( RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl ); RationalImpl convert( double );} )106 forall( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl ); RationalImpl convert( double );} ) 107 107 Rational(RationalImpl) narrow( double f, RationalImpl md ); 108 108
Note:
See TracChangeset
for help on using the changeset viewer.