Changeset 09687aa for src/libcfa


Ignore:
Timestamp:
Dec 7, 2017, 1:10:51 PM (6 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
5e1adb5
Parents:
92494fd
Message:

complete conversion of iostream/fstream to use references

Location:
src/libcfa
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/fstream

    r92494fd r09687aa  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul  7 08:32:38 2017
    13 // Update Count     : 117
     12// Last Modified On : Thu Dec  7 08:06:11 2017
     13// Update Count     : 129
    1414//
    1515
     
    3030
    3131// private
    32 _Bool sepPrt( ofstream * );
    33 void sepReset( ofstream * );
    34 void sepReset( ofstream *, _Bool );
    35 const char * sepGetCur( ofstream * );
    36 void sepSetCur( ofstream *, const char * );
    37 _Bool getNL( ofstream * );
    38 void setNL( ofstream *, _Bool );
     32_Bool sepPrt( ofstream & );
     33void sepReset( ofstream & );
     34void sepReset( ofstream &, _Bool );
     35const char * sepGetCur( ofstream & );
     36void sepSetCur( ofstream &, const char * );
     37_Bool getNL( ofstream & );
     38void setNL( ofstream &, _Bool );
    3939
    4040// public
    41 void sepOn( ofstream * );
    42 void sepOff( ofstream * );
    43 _Bool sepDisable( ofstream * );
    44 _Bool sepEnable( ofstream * );
     41void sepOn( ofstream & );
     42void sepOff( ofstream & );
     43_Bool sepDisable( ofstream & );
     44_Bool sepEnable( ofstream & );
    4545
    46 const char * sepGet( ofstream * );
    47 void sepSet( ofstream *, const char * );
    48 const char * sepGetTuple( ofstream * );
    49 void sepSetTuple( ofstream *, const char * );
     46const char * sepGet( ofstream & );
     47void sepSet( ofstream &, const char * );
     48const char * sepGetTuple( ofstream & );
     49void sepSetTuple( ofstream &, const char * );
    5050
    51 int fail( ofstream * );
    52 int flush( ofstream * );
    53 void open( ofstream *, const char * name, const char * mode );
    54 void close( ofstream * );
    55 ofstream * write( ofstream *, const char * data, unsigned long int size );
    56 int fmt( ofstream *, const char fmt[], ... );
     51int fail( ofstream & );
     52int flush( ofstream & );
     53void open( ofstream &, const char * name, const char * mode );
     54void close( ofstream & );
     55ofstream & write( ofstream &, const char * data, unsigned long int size );
     56int fmt( ofstream &, const char fmt[], ... );
    5757
    58 void ?{}( ofstream & );
     58void ?{}( ofstream & os );
     59void ?{}( ofstream & os, const char * name, const char * mode );
    5960
    60 extern ofstream * sout, * serr;
     61extern ofstream & sout, & serr;
    6162
    62 // implement context istream
     63
    6364struct ifstream {
    6465        void * file;
    6566}; // ifstream
    6667
    67 int fail( ifstream * is );
    68 int eof( ifstream * is );
    69 void open( ifstream * is, const char * name, const char * mode );
    70 void close( ifstream * is );
    71 ifstream * read( ifstream * is, char * data, unsigned long int size );
    72 ifstream * ungetc( ifstream * is, char c );
    73 int fmt( ifstream *, const char fmt[], ... );
     68// public
     69int fail( ifstream & is );
     70int eof( ifstream & is );
     71void open( ifstream & is, const char * name );
     72void close( ifstream & is );
     73ifstream & read( ifstream & is, char * data, unsigned long int size );
     74ifstream & ungetc( ifstream & is, char c );
     75int fmt( ifstream &, const char fmt[], ... );
    7476
    75 extern ifstream * sin;
     77void ?{}( ifstream & is );
     78void ?{}( ifstream & is, const char * name );
     79
     80extern ifstream & sin;
    7681
    7782// Local Variables: //
  • src/libcfa/fstream.c

    r92494fd r09687aa  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul 20 15:20:49 2017
    13 // Update Count     : 252
     12// Last Modified On : Thu Dec  7 08:35:01 2017
     13// Update Count     : 270
    1414//
    1515
     
    2727#define IO_MSG "I/O error: "
    2828
    29 void ?{}( ofstream & this, void * file, _Bool sepDefault, _Bool sepOnOff, const char * separator, const char * tupleSeparator ) {
    30         this.file = file;
    31         this.sepDefault = sepDefault;
    32         this.sepOnOff = sepOnOff;
    33         sepSet( &this, separator );
    34         sepSetCur( &this, sepGet( &this ) );
    35         sepSetTuple( &this, tupleSeparator );
     29void ?{}( ofstream & os, void * file, _Bool sepDefault, _Bool sepOnOff, const char * separator, const char * tupleSeparator ) {
     30        os.file = file;
     31        os.sepDefault = sepDefault;
     32        os.sepOnOff = sepOnOff;
     33        sepSet( os, separator );
     34        sepSetCur( os, sepGet( os ) );
     35        sepSetTuple( os, tupleSeparator );
    3636}
    3737
    3838// private
    39 _Bool sepPrt( ofstream * os ) { setNL( os, false ); return os->sepOnOff; }
    40 void sepReset( ofstream * os ) { os->sepOnOff = os->sepDefault; }
    41 void sepReset( ofstream * os, _Bool reset ) { os->sepDefault = reset; os->sepOnOff = os->sepDefault; }
    42 const char * sepGetCur( ofstream * os ) { return os->sepCur; }
    43 void sepSetCur( ofstream * os, const char * sepCur ) { os->sepCur = sepCur; }
    44 _Bool getNL( ofstream * os ) { return os->sawNL; }
    45 void setNL( ofstream * os, _Bool state ) { os->sawNL = state; }
     39_Bool sepPrt( ofstream & os ) { setNL( os, false ); return os.sepOnOff; }
     40void sepReset( ofstream & os ) { os.sepOnOff = os.sepDefault; }
     41void sepReset( ofstream & os, _Bool reset ) { os.sepDefault = reset; os.sepOnOff = os.sepDefault; }
     42const char * sepGetCur( ofstream & os ) { return os.sepCur; }
     43void sepSetCur( ofstream & os, const char * sepCur ) { os.sepCur = sepCur; }
     44_Bool getNL( ofstream & os ) { return os.sawNL; }
     45void setNL( ofstream & os, _Bool state ) { os.sawNL = state; }
    4646
    4747// public
    48 void sepOn( ofstream * os ) { os->sepOnOff = ! getNL( os ); }
    49 void sepOff( ofstream * os ) { os->sepOnOff = false; }
    50 
    51 _Bool sepDisable( ofstream *os ) {
    52         _Bool temp = os->sepDefault;
    53         os->sepDefault = false;
     48void ?{}( ofstream & os ) {}
     49
     50void ?{}( ofstream & os, const char * name, const char * mode ) {
     51        open( os, name, mode );
     52}
     53
     54void sepOn( ofstream & os ) { os.sepOnOff = ! getNL( os ); }
     55void sepOff( ofstream & os ) { os.sepOnOff = false; }
     56
     57_Bool sepDisable( ofstream & os ) {
     58        _Bool temp = os.sepDefault;
     59        os.sepDefault = false;
    5460        sepReset( os );
    5561        return temp;
    5662} // sepDisable
    5763
    58 _Bool sepEnable( ofstream *os ) {
    59         _Bool temp = os->sepDefault;
    60         os->sepDefault = true;
    61         if ( os->sepOnOff ) sepReset( os );                                     // start of line ?
     64_Bool sepEnable( ofstream & os ) {
     65        _Bool temp = os.sepDefault;
     66        os.sepDefault = true;
     67        if ( os.sepOnOff ) sepReset( os );                                      // start of line ?
    6268        return temp;
    6369} // sepEnable
    6470
    65 const char * sepGet( ofstream * os ) { return os->separator; }
    66 void sepSet( ofstream * os, const char * s ) {
     71const char * sepGet( ofstream & os ) { return os.separator; }
     72void sepSet( ofstream & os, const char * s ) {
    6773        assert( s );
    68         strncpy( os->separator, s, sepSize - 1 );
    69         os->separator[sepSize - 1] = '\0';
     74        strncpy( os.separator, s, sepSize - 1 );
     75        os.separator[sepSize - 1] = '\0';
    7076} // sepSet
    7177
    72 const char * sepGetTuple( ofstream * os ) { return os->tupleSeparator; }
    73 void sepSetTuple( ofstream * os, const char * s ) {
     78const char * sepGetTuple( ofstream & os ) { return os.tupleSeparator; }
     79void sepSetTuple( ofstream & os, const char * s ) {
    7480        assert( s );
    75         strncpy( os->tupleSeparator, s, sepSize - 1 );
    76         os->tupleSeparator[sepSize - 1] = '\0';
     81        strncpy( os.tupleSeparator, s, sepSize - 1 );
     82        os.tupleSeparator[sepSize - 1] = '\0';
    7783} // sepSet
    7884
    79 int fail( ofstream * os ) {
    80         return ferror( (FILE *)(os->file) );
     85int fail( ofstream & os ) {
     86        return ferror( (FILE *)(os.file) );
    8187} // fail
    8288
    83 int flush( ofstream * os ) {
    84         return fflush( (FILE *)(os->file) );
     89int flush( ofstream & os ) {
     90        return fflush( (FILE *)(os.file) );
    8591} // flush
    8692
    87 void open( ofstream * os, const char * name, const char * mode ) {
     93void open( ofstream & os, const char * name, const char * mode ) {
    8894        FILE *file = fopen( name, mode );
    8995        if ( file == 0 ) {                                                                      // do not change unless successful
     
    9298                exit( EXIT_FAILURE );
    9399        } // if
    94         ?{}( *os, file, true, false, " ", ", " );
     100        (os){ file, true, false, " ", ", " };
    95101} // open
    96102
    97 void close( ofstream * os ) {
    98         if ( (FILE *)(os->file) == stdout || (FILE *)(os->file) == stderr ) return;
    99 
    100         if ( fclose( (FILE *)(os->file) ) == EOF ) {
     103void close( ofstream & os ) {
     104        if ( (FILE *)(os.file) == stdout || (FILE *)(os.file) == stderr ) return;
     105
     106        if ( fclose( (FILE *)(os.file) ) == EOF ) {
    101107                perror( IO_MSG "close output" );
    102108        } // if
    103109} // close
    104110
    105 ofstream * write( ofstream * os, const char * data, unsigned long int size ) {
     111ofstream & write( ofstream & os, const char * data, unsigned long int size ) {
    106112        if ( fail( os ) ) {
    107113                fprintf( stderr, "attempt write I/O on failed stream\n" );
     
    109115        } // if
    110116
    111         if ( fwrite( data, 1, size, (FILE *)(os->file) ) != size ) {
     117        if ( fwrite( data, 1, size, (FILE *)(os.file) ) != size ) {
    112118                perror( IO_MSG "write" );
    113119                exit( EXIT_FAILURE );
     
    116122} // write
    117123
    118 int fmt( ofstream * os, const char format[], ... ) {
     124int fmt( ofstream & os, const char format[], ... ) {
    119125        va_list args;
    120126        va_start( args, format );
    121         int len = vfprintf( (FILE *)(os->file), format, args );
     127        int len = vfprintf( (FILE *)(os.file), format, args );
    122128        if ( len == EOF ) {
    123                 if ( ferror( (FILE *)(os->file) ) ) {
     129                if ( ferror( (FILE *)(os.file) ) ) {
    124130                        fprintf( stderr, "invalid write\n" );
    125131                        exit( EXIT_FAILURE );
     
    133139
    134140static ofstream soutFile = { (FILE *)(&_IO_2_1_stdout_), true, false, " ", ", " };
    135 ofstream *sout = &soutFile;
     141ofstream & sout = soutFile;
    136142static ofstream serrFile = { (FILE *)(&_IO_2_1_stderr_), true, false, " ", ", " };
    137 ofstream *serr = &serrFile;
     143ofstream & serr = serrFile;
    138144
    139145
    140146//---------------------------------------
    141147
    142 
    143 int fail( ifstream * is ) {
    144         return ferror( (FILE *)(is->file) );
     148// private
     149void ?{}( ifstream & is, void * file ) {
     150        is.file = file;
     151}
     152
     153// public
     154void ?{}( ifstream & is ) {}
     155
     156void ?{}( ifstream & is, const char * name ) {
     157        open( is, name );
     158}
     159
     160int fail( ifstream & is ) {
     161        return ferror( (FILE *)(is.file) );
    145162} // fail
    146163
    147 int eof( ifstream * is ) {
    148         return feof( (FILE *)(is->file) );
     164int eof( ifstream & is ) {
     165        return feof( (FILE *)(is.file) );
    149166} // eof
    150167
    151 void open( ifstream * is, const char * name, const char * mode ) {
    152         FILE *file = fopen( name, mode );
     168void open( ifstream & is, const char * name ) {
     169        FILE *file = fopen( name, "r" );
    153170        if ( file == 0 ) {                                                                      // do not change unless successful
    154171                fprintf( stderr, IO_MSG "open input file \"%s\", ", name );
     
    156173                exit( EXIT_FAILURE );
    157174        } // if
    158         is->file = file;
     175        is.file = file;
    159176} // open
    160177
    161 void close( ifstream * is ) {
    162         if ( (FILE *)(is->file) == stdin ) return;
    163 
    164         if ( fclose( (FILE *)(is->file) ) == EOF ) {
     178void close( ifstream & is ) {
     179        if ( (FILE *)(is.file) == stdin ) return;
     180
     181        if ( fclose( (FILE *)(is.file) ) == EOF ) {
    165182                perror( IO_MSG "close input" );
    166183        } // if
    167184} // close
    168185
    169 ifstream * read( ifstream * is, char * data, unsigned long int size ) {
     186ifstream & read( ifstream & is, char * data, unsigned long int size ) {
    170187        if ( fail( is ) ) {
    171188                fprintf( stderr, "attempt read I/O on failed stream\n" );
     
    173190        } // if
    174191
    175         if ( fread( data, size, 1, (FILE *)(is->file) ) == 0 ) {
     192        if ( fread( data, size, 1, (FILE *)(is.file) ) == 0 ) {
    176193                perror( IO_MSG "read" );
    177194                exit( EXIT_FAILURE );
     
    180197} // read
    181198
    182 ifstream *ungetc( ifstream * is, char c ) {
     199ifstream &ungetc( ifstream & is, char c ) {
    183200        if ( fail( is ) ) {
    184201                fprintf( stderr, "attempt ungetc I/O on failed stream\n" );
     
    186203        } // if
    187204
    188         if ( ungetc( c, (FILE *)(is->file) ) == EOF ) {
     205        if ( ungetc( c, (FILE *)(is.file) ) == EOF ) {
    189206                perror( IO_MSG "ungetc" );
    190207                exit( EXIT_FAILURE );
     
    193210} // ungetc
    194211
    195 int fmt( ifstream * is, const char format[], ... ) {
     212int fmt( ifstream & is, const char format[], ... ) {
    196213        va_list args;
    197214
    198215        va_start( args, format );
    199         int len = vfscanf( (FILE *)(is->file), format, args );
     216        int len = vfscanf( (FILE *)(is.file), format, args );
    200217        if ( len == EOF ) {
    201                 if ( ferror( (FILE *)(is->file) ) ) {
     218                if ( ferror( (FILE *)(is.file) ) ) {
    202219                        fprintf( stderr, "invalid read\n" );
    203220                        exit( EXIT_FAILURE );
     
    210227
    211228static ifstream sinFile = { (FILE *)(&_IO_2_1_stdin_) };
    212 ifstream *sin = &sinFile;
     229ifstream & sin = sinFile;
    213230
    214231// Local Variables: //
  • src/libcfa/gmp

    r92494fd r09687aa  
    1010// Created On       : Tue Apr 19 08:43:43 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Sep  4 09:54:33 2017
    13 // Update Count     : 20
     12// Last Modified On : Thu Dec  7 09:10:41 2017
     13// Update Count     : 21
    1414//
    1515
     
    257257// I/O
    258258static inline forall( dtype istype | istream( istype ) )
    259 istype * ?|?( istype * is, Int & mp ) {
     259istype & ?|?( istype & is, Int & mp ) {
    260260        gmp_scanf( "%Zd", &mp );
    261261        return is;
     
    263263
    264264static inline forall( dtype ostype | ostream( ostype ) )
    265 ostype * ?|?( ostype * os, Int mp ) {
     265ostype & ?|?( ostype & os, Int mp ) {
    266266        if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    267267        gmp_printf( "%Zd", mp.mpz );
  • src/libcfa/iostream

    r92494fd r09687aa  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Oct 10 14:51:10 2017
    13 // Update Count     : 140
     12// Last Modified On : Wed Dec  6 23:03:30 2017
     13// Update Count     : 144
    1414//
    1515
     
    2020trait ostream( dtype ostype ) {
    2121        // private
    22         _Bool sepPrt( ostype * );                                                       // return separator state (on/off)
    23         void sepReset( ostype * );                                                      // set separator state to default state
    24         void sepReset( ostype *, _Bool );                                       // set separator and default state
    25         const char * sepGetCur( ostype * );                                     // get current separator string
    26         void sepSetCur( ostype *, const char * );                       // set current separator string
    27         _Bool getNL( ostype * );                                                        // check newline
    28         void setNL( ostype *, _Bool );                                          // saw newline
     22        _Bool sepPrt( ostype & );                                                       // return separator state (on/off)
     23        void sepReset( ostype & );                                                      // set separator state to default state
     24        void sepReset( ostype &, _Bool );                                       // set separator and default state
     25        const char * sepGetCur( ostype & );                                     // get current separator string
     26        void sepSetCur( ostype &, const char * );                       // set current separator string
     27        _Bool getNL( ostype & );                                                        // check newline
     28        void setNL( ostype &, _Bool );                                          // saw newline
    2929        // public
    30         void sepOn( ostype * );                                                         // turn separator state on
    31         void sepOff( ostype * );                                                        // turn separator state off
    32         _Bool sepDisable( ostype * );                                           // set default state to off, and return previous state
    33         _Bool sepEnable( ostype * );                                            // set default state to on, and return previous state
     30        void sepOn( ostype & );                                                         // turn separator state on
     31        void sepOff( ostype & );                                                        // turn separator state off
     32        _Bool sepDisable( ostype & );                                           // set default state to off, and return previous state
     33        _Bool sepEnable( ostype & );                                            // set default state to on, and return previous state
    3434
    35         const char * sepGet( ostype * );                                        // get separator string
    36         void sepSet( ostype *, const char * );                          // set separator to string (15 character maximum)
    37         const char * sepGetTuple( ostype * );                           // get tuple separator string
    38         void sepSetTuple( ostype *, const char * );                     // set tuple separator to string (15 character maximum)
     35        const char * sepGet( ostype & );                                        // get separator string
     36        void sepSet( ostype &, const char * );                          // set separator to string (15 character maximum)
     37        const char * sepGetTuple( ostype & );                           // get tuple separator string
     38        void sepSetTuple( ostype &, const char * );                     // set tuple separator to string (15 character maximum)
    3939
    40         int fail( ostype * );
    41         int flush( ostype * );
    42         void open( ostype * os, const char * name, const char * mode );
    43         void close( ostype * os );
    44         ostype * write( ostype *, const char *, unsigned long int );
    45         int fmt( ostype *, const char fmt[], ... );
     40        int fail( ostype & );
     41        int flush( ostype & );
     42        void open( ostype & os, const char * name, const char * mode );
     43        void close( ostype & os );
     44        ostype & write( ostype &, const char *, unsigned long int );
     45        int fmt( ostype &, const char fmt[], ... );
    4646}; // ostream
    4747
    4848// trait writeable( otype T ) {
    49 //      forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, T );
     49//      forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, T );
    5050// }; // writeable
    5151
    5252trait writeable( otype T, dtype ostype | ostream( ostype ) ) {
    53         ostype * ?|?( ostype *, T );
     53        ostype & ?|?( ostype &, T );
    5454}; // writeable
    5555
    5656// implement writable for intrinsic types
    5757
    58 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, char );
    59 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, signed char );
    60 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, unsigned char );
     58forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, char );
     59forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, signed char );
     60forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, unsigned char );
    6161
    62 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, short int );
    63 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, unsigned short int );
    64 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, int );
    65 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, unsigned int );
    66 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, long int );
    67 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, long long int );
    68 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, unsigned long int );
    69 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, unsigned long long int );
     62forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, short int );
     63forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, unsigned short int );
     64forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, int );
     65forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, unsigned int );
     66forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, long int );
     67forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, long long int );
     68forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, unsigned long int );
     69forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, unsigned long long int );
    7070
    71 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, float ); // FIX ME: should not be required
    72 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, double );
    73 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, long double );
     71forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, float ); // FIX ME: should not be required
     72forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, double );
     73forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, long double );
    7474
    75 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, float _Complex );
    76 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, double _Complex );
    77 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, long double _Complex );
     75forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, float _Complex );
     76forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, double _Complex );
     77forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, long double _Complex );
    7878
    79 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, const char * );
    80 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, const char16_t * );
     79forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, const char * );
     80forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, const char16_t * );
    8181#if ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 ) // char32_t == wchar_t => ambiguous
    82 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, const char32_t * );
     82forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, const char32_t * );
    8383#endif // ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 )
    84 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, const wchar_t * );
    85 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, const void * );
     84forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, const wchar_t * );
     85forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, const void * );
    8686
    8787// tuples
    88 forall( dtype ostype, otype T, ttype Params | writeable( T, ostype ) | { ostype * ?|?( ostype *, Params ); } )
    89 ostype * ?|?( ostype * os, T arg, Params rest );
     88forall( dtype ostype, otype T, ttype Params | writeable( T, ostype ) | { ostype & ?|?( ostype &, Params ); } )
     89ostype & ?|?( ostype & os, T arg, Params rest );
    9090
    9191// manipulators
    92 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, ostype * (*)( ostype * ) );
    93 forall( dtype ostype | ostream( ostype ) ) ostype * endl( ostype * );
    94 forall( dtype ostype | ostream( ostype ) ) ostype * sep( ostype * );
    95 forall( dtype ostype | ostream( ostype ) ) ostype * sepTuple( ostype * );
    96 forall( dtype ostype | ostream( ostype ) ) ostype * sepOn( ostype * );
    97 forall( dtype ostype | ostream( ostype ) ) ostype * sepOff( ostype * );
    98 forall( dtype ostype | ostream( ostype ) ) ostype * sepDisable( ostype * );
    99 forall( dtype ostype | ostream( ostype ) ) ostype * sepEnable( ostype * );
     92forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, ostype & (*)( ostype & ) );
     93forall( dtype ostype | ostream( ostype ) ) ostype & endl( ostype & );
     94forall( dtype ostype | ostream( ostype ) ) ostype & sep( ostype & );
     95forall( dtype ostype | ostream( ostype ) ) ostype & sepTuple( ostype & );
     96forall( dtype ostype | ostream( ostype ) ) ostype & sepOn( ostype & );
     97forall( dtype ostype | ostream( ostype ) ) ostype & sepOff( ostype & );
     98forall( dtype ostype | ostream( ostype ) ) ostype & sepDisable( ostype & );
     99forall( dtype ostype | ostream( ostype ) ) ostype & sepEnable( ostype & );
    100100
    101101// writes the range [begin, end) to the given stream
    102102forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) )
    103 void write( iterator_type begin, iterator_type end, ostype * os );
     103void write( iterator_type begin, iterator_type end, ostype & os );
    104104
    105105forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) )
    106 void write_reverse( iterator_type begin, iterator_type end, ostype * os );
     106void write_reverse( iterator_type begin, iterator_type end, ostype & os );
    107107
    108108//---------------------------------------
    109109
    110110trait istream( dtype istype ) {
    111         int fail( istype * );
    112         int eof( istype * );
    113         void open( istype * is, const char * name, const char * mode );
    114         void close( istype * is );
    115         istype * read( istype *, char *, unsigned long int );
    116         istype * ungetc( istype *, char );
    117         int fmt( istype *, const char fmt[], ... );
     111        int fail( istype & );
     112        int eof( istype & );
     113        void open( istype & is, const char * name );
     114        void close( istype & is );
     115        istype & read( istype &, char *, unsigned long int );
     116        istype & ungetc( istype &, char );
     117        int fmt( istype &, const char fmt[], ... );
    118118}; // istream
    119119
    120120trait readable( otype T ) {
    121         forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, T );
     121        forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, T );
    122122}; // readable
    123123
    124 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, char & );
    125 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, signed char & );
    126 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, unsigned char & );
     124forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, char & );
     125forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, signed char & );
     126forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, unsigned char & );
    127127
    128 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, short int & );
    129 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, unsigned short int & );
    130 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, int & );
    131 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, unsigned int & );
    132 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, long int & );
    133 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, long long int & );
    134 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, unsigned long int & );
    135 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, unsigned long long int & );
     128forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, short int & );
     129forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, unsigned short int & );
     130forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, int & );
     131forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, unsigned int & );
     132forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, long int & );
     133forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, long long int & );
     134forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, unsigned long int & );
     135forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, unsigned long long int & );
    136136
    137 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, float & );
    138 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, double & );
    139 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, long double & );
     137forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, float & );
     138forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, double & );
     139forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, long double & );
    140140
    141 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, float _Complex & );
    142 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, double _Complex & );
    143 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, long double _Complex & );
     141forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, float _Complex & );
     142forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, double _Complex & );
     143forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, long double _Complex & );
    144144
    145145struct _Istream_cstrUC { char * s; };
    146146_Istream_cstrUC cstr( char * );
    147 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, _Istream_cstrUC );
     147forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, _Istream_cstrUC );
    148148
    149149struct _Istream_cstrC { char * s; int size; };
    150150_Istream_cstrC cstr( char *, int size );
    151 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, _Istream_cstrC );
     151forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, _Istream_cstrC );
    152152
    153153// Local Variables: //
  • src/libcfa/iostream.c

    r92494fd r09687aa  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Oct 10 14:51:09 2017
    13 // Update Count     : 424
     12// Last Modified On : Wed Dec  6 23:03:43 2017
     13// Update Count     : 426
    1414//
    1515
     
    2525
    2626forall( dtype ostype | ostream( ostype ) )
    27 ostype * ?|?( ostype * os, char ch ) {
     27ostype & ?|?( ostype & os, char ch ) {
    2828        fmt( os, "%c", ch );
    2929        if ( ch == '\n' ) setNL( os, true );
     
    3333
    3434forall( dtype ostype | ostream( ostype ) )
    35 ostype * ?|?( ostype * os, signed char c ) {
     35ostype & ?|?( ostype & os, signed char c ) {
    3636        if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    3737        fmt( os, "%hhd", c );
     
    4040
    4141forall( dtype ostype | ostream( ostype ) )
    42 ostype * ?|?( ostype * os, unsigned char c ) {
     42ostype & ?|?( ostype & os, unsigned char c ) {
    4343        if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    4444        fmt( os, "%hhu", c );
     
    4747
    4848forall( dtype ostype | ostream( ostype ) )
    49 ostype * ?|?( ostype * os, short int si ) {
     49ostype & ?|?( ostype & os, short int si ) {
    5050        if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    5151        fmt( os, "%hd", si );
     
    5454
    5555forall( dtype ostype | ostream( ostype ) )
    56 ostype * ?|?( ostype * os, unsigned short int usi ) {
     56ostype & ?|?( ostype & os, unsigned short int usi ) {
    5757        if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    5858        fmt( os, "%hu", usi );
     
    6161
    6262forall( dtype ostype | ostream( ostype ) )
    63 ostype * ?|?( ostype * os, int i ) {
     63ostype & ?|?( ostype & os, int i ) {
    6464        if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    6565        fmt( os, "%d", i );
     
    6868
    6969forall( dtype ostype | ostream( ostype ) )
    70 ostype * ?|?( ostype * os, unsigned int ui ) {
     70ostype & ?|?( ostype & os, unsigned int ui ) {
    7171        if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    7272        fmt( os, "%u", ui );
     
    7575
    7676forall( dtype ostype | ostream( ostype ) )
    77 ostype * ?|?( ostype * os, long int li ) {
     77ostype & ?|?( ostype & os, long int li ) {
    7878        if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    7979        fmt( os, "%ld", li );
     
    8282
    8383forall( dtype ostype | ostream( ostype ) )
    84 ostype * ?|?( ostype * os, unsigned long int uli ) {
     84ostype & ?|?( ostype & os, unsigned long int uli ) {
    8585        if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    8686        fmt( os, "%lu", uli );
     
    8989
    9090forall( dtype ostype | ostream( ostype ) )
    91 ostype * ?|?( ostype * os, long long int lli ) {
     91ostype & ?|?( ostype & os, long long int lli ) {
    9292        if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    9393        fmt( os, "%lld", lli );
     
    9696
    9797forall( dtype ostype | ostream( ostype ) )
    98 ostype * ?|?( ostype * os, unsigned long long int ulli ) {
     98ostype & ?|?( ostype & os, unsigned long long int ulli ) {
    9999        if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    100100        fmt( os, "%llu", ulli );
     
    103103
    104104forall( dtype ostype | ostream( ostype ) )
    105 ostype * ?|?( ostype * os, float f ) {
     105ostype & ?|?( ostype & os, float f ) {
    106106        if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    107107        fmt( os, "%g", f );
     
    110110
    111111forall( dtype ostype | ostream( ostype ) )
    112 ostype * ?|?( ostype * os, double d ) {
     112ostype & ?|?( ostype & os, double d ) {
    113113        if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    114114        fmt( os, "%.*lg", DBL_DIG, d );
     
    117117
    118118forall( dtype ostype | ostream( ostype ) )
    119 ostype * ?|?( ostype * os, long double ld ) {
     119ostype & ?|?( ostype & os, long double ld ) {
    120120        if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    121121        fmt( os, "%.*Lg", LDBL_DIG, ld );
     
    124124
    125125forall( dtype ostype | ostream( ostype ) )
    126 ostype * ?|?( ostype * os, float _Complex fc ) {
     126ostype & ?|?( ostype & os, float _Complex fc ) {
    127127        if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    128128        fmt( os, "%g%+gi", crealf( fc ), cimagf( fc ) );
     
    131131
    132132forall( dtype ostype | ostream( ostype ) )
    133 ostype * ?|?( ostype * os, double _Complex dc ) {
     133ostype & ?|?( ostype & os, double _Complex dc ) {
    134134        if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    135135        fmt( os, "%.*lg%+.*lgi", DBL_DIG, creal( dc ), DBL_DIG, cimag( dc ) );
     
    138138
    139139forall( dtype ostype | ostream( ostype ) )
    140 ostype * ?|?( ostype * os, long double _Complex ldc ) {
     140ostype & ?|?( ostype & os, long double _Complex ldc ) {
    141141        if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    142142        fmt( os, "%.*Lg%+.*Lgi", LDBL_DIG, creall( ldc ), LDBL_DIG, cimagl( ldc ) );
     
    145145
    146146forall( dtype ostype | ostream( ostype ) )
    147 ostype * ?|?( ostype * os, const char * str ) {
     147ostype & ?|?( ostype & os, const char * str ) {
    148148        enum { Open = 1, Close, OpenClose };
    149149        static const unsigned char mask[256] @= {
     
    185185
    186186forall( dtype ostype | ostream( ostype ) )
    187 ostype * ?|?( ostype * os, const char16_t * str ) {
     187ostype & ?|?( ostype & os, const char16_t * str ) {
    188188        if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    189189        fmt( os, "%ls", str );
     
    193193#if ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 ) // char32_t == wchar_t => ambiguous
    194194forall( dtype ostype | ostream( ostype ) )
    195 ostype * ?|?( ostype * os, const char32_t * str ) {
     195ostype & ?|?( ostype & os, const char32_t * str ) {
    196196        if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    197197        fmt( os, "%ls", str );
     
    201201
    202202forall( dtype ostype | ostream( ostype ) )
    203 ostype * ?|?( ostype * os, const wchar_t * str ) {
     203ostype & ?|?( ostype & os, const wchar_t * str ) {
    204204        if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    205205        fmt( os, "%ls", str );
     
    208208
    209209forall( dtype ostype | ostream( ostype ) )
    210 ostype * ?|?( ostype * os, const void * p ) {
     210ostype & ?|?( ostype & os, const void * p ) {
    211211        if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    212212        fmt( os, "%p", p );
     
    216216
    217217// tuples
    218 forall( dtype ostype, otype T, ttype Params | writeable( T, ostype ) | { ostype * ?|?( ostype *, Params ); } )
    219 ostype * ?|?( ostype * os, T arg, Params rest ) {
     218forall( dtype ostype, otype T, ttype Params | writeable( T, ostype ) | { ostype & ?|?( ostype &, Params ); } )
     219ostype & ?|?( ostype & os, T arg, Params rest ) {
    220220        os | arg;                                                                                       // print first argument
    221221        sepSetCur( os, sepGetTuple( os ) );                                     // switch to tuple separator
     
    228228// manipulators
    229229forall( dtype ostype | ostream( ostype ) )
    230 ostype * ?|?( ostype * os, ostype * (* manip)( ostype * ) ) {
     230ostype & ?|?( ostype & os, ostype & (* manip)( ostype & ) ) {
    231231        return manip( os );
    232232} // ?|?
    233233
    234234forall( dtype ostype | ostream( ostype ) )
    235 ostype * sep( ostype * os ) {
     235ostype & sep( ostype & os ) {
    236236        os | sepGet( os );
    237237        return os;
     
    239239
    240240forall( dtype ostype | ostream( ostype ) )
    241 ostype * sepTuple( ostype * os ) {
     241ostype & sepTuple( ostype & os ) {
    242242        os | sepGetTuple( os );
    243243        return os;
     
    245245
    246246forall( dtype ostype | ostream( ostype ) )
    247 ostype * endl( ostype * os ) {
     247ostype & endl( ostype & os ) {
    248248        os | '\n';
    249249        setNL( os, true );
     
    254254
    255255forall( dtype ostype | ostream( ostype ) )
    256 ostype * sepOn( ostype * os ) {
     256ostype & sepOn( ostype & os ) {
    257257        sepOn( os );
    258258        return os;
     
    260260
    261261forall( dtype ostype | ostream( ostype ) )
    262 ostype * sepOff( ostype * os ) {
     262ostype & sepOff( ostype & os ) {
    263263        sepOff( os );
    264264        return os;
     
    266266
    267267forall( dtype ostype | ostream( ostype ) )
    268 ostype * sepEnable( ostype * os ) {
     268ostype & sepEnable( ostype & os ) {
    269269        sepEnable( os );
    270270        return os;
     
    272272
    273273forall( dtype ostype | ostream( ostype ) )
    274 ostype * sepDisable( ostype * os ) {
     274ostype & sepDisable( ostype & os ) {
    275275        sepDisable( os );
    276276        return os;
     
    280280
    281281forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) )
    282 void write( iterator_type begin, iterator_type end, ostype * os ) {
     282void write( iterator_type begin, iterator_type end, ostype & os ) {
    283283        void print( elt_type i ) { os | i; }
    284284        for_each( begin, end, print );
     
    286286
    287287forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) )
    288 void write_reverse( iterator_type begin, iterator_type end, ostype * os ) {
     288void write_reverse( iterator_type begin, iterator_type end, ostype & os ) {
    289289        void print( elt_type i ) { os | i; }
    290290        for_each_reverse( begin, end, print );
     
    294294
    295295forall( dtype istype | istream( istype ) )
    296 istype * ?|?( istype * is, char & c ) {
     296istype & ?|?( istype & is, char & c ) {
    297297        fmt( is, "%c", &c );                                                            // must pass pointer through varg to fmt
    298298        return is;
     
    300300
    301301forall( dtype istype | istream( istype ) )
    302 istype * ?|?( istype * is, signed char & sc ) {
     302istype & ?|?( istype & is, signed char & sc ) {
    303303        fmt( is, "%hhd", &sc );
    304304        return is;
     
    306306
    307307forall( dtype istype | istream( istype ) )
    308 istype * ?|?( istype * is, unsigned char & usc ) {
     308istype & ?|?( istype & is, unsigned char & usc ) {
    309309        fmt( is, "%hhu", &usc );
    310310        return is;
     
    312312
    313313forall( dtype istype | istream( istype ) )
    314 istype * ?|?( istype * is, short int & si ) {
     314istype & ?|?( istype & is, short int & si ) {
    315315        fmt( is, "%hd", &si );
    316316        return is;
     
    318318
    319319forall( dtype istype | istream( istype ) )
    320 istype * ?|?( istype * is, unsigned short int & usi ) {
     320istype & ?|?( istype & is, unsigned short int & usi ) {
    321321        fmt( is, "%hu", &usi );
    322322        return is;
     
    324324
    325325forall( dtype istype | istream( istype ) )
    326 istype * ?|?( istype * is, int & i ) {
     326istype & ?|?( istype & is, int & i ) {
    327327        fmt( is, "%d", &i );
    328328        return is;
     
    330330
    331331forall( dtype istype | istream( istype ) )
    332 istype * ?|?( istype * is, unsigned int & ui ) {
     332istype & ?|?( istype & is, unsigned int & ui ) {
    333333        fmt( is, "%u", &ui );
    334334        return is;
     
    336336
    337337forall( dtype istype | istream( istype ) )
    338 istype * ?|?( istype * is, long int & li ) {
     338istype & ?|?( istype & is, long int & li ) {
    339339        fmt( is, "%ld", &li );
    340340        return is;
     
    342342
    343343forall( dtype istype | istream( istype ) )
    344 istype * ?|?( istype * is, unsigned long int & ulli ) {
     344istype & ?|?( istype & is, unsigned long int & ulli ) {
    345345        fmt( is, "%lu", &ulli );
    346346        return is;
     
    348348
    349349forall( dtype istype | istream( istype ) )
    350 istype * ?|?( istype * is, long long int & lli ) {
     350istype & ?|?( istype & is, long long int & lli ) {
    351351        fmt( is, "%lld", &lli );
    352352        return is;
     
    354354
    355355forall( dtype istype | istream( istype ) )
    356 istype * ?|?( istype * is, unsigned long long int & ulli ) {
     356istype & ?|?( istype & is, unsigned long long int & ulli ) {
    357357        fmt( is, "%llu", &ulli );
    358358        return is;
     
    361361
    362362forall( dtype istype | istream( istype ) )
    363 istype * ?|?( istype * is, float & f ) {
     363istype & ?|?( istype & is, float & f ) {
    364364        fmt( is, "%f", &f );
    365365        return is;
     
    367367
    368368forall( dtype istype | istream( istype ) )
    369 istype * ?|?( istype * is, double & d ) {
     369istype & ?|?( istype & is, double & d ) {
    370370        fmt( is, "%lf", &d );
    371371        return is;
     
    373373
    374374forall( dtype istype | istream( istype ) )
    375 istype * ?|?( istype * is, long double & ld ) {
     375istype & ?|?( istype & is, long double & ld ) {
    376376        fmt( is, "%Lf", &ld );
    377377        return is;
     
    380380
    381381forall( dtype istype | istream( istype ) )
    382 istype * ?|?( istype * is, float _Complex & fc ) {
     382istype & ?|?( istype & is, float _Complex & fc ) {
    383383        float re, im;
    384384        fmt( is, "%g%gi", &re, &im );
     
    388388
    389389forall( dtype istype | istream( istype ) )
    390 istype * ?|?( istype * is, double _Complex & dc ) {
     390istype & ?|?( istype & is, double _Complex & dc ) {
    391391        double re, im;
    392392        fmt( is, "%lf%lfi", &re, &im );
     
    396396
    397397forall( dtype istype | istream( istype ) )
    398 istype * ?|?( istype * is, long double _Complex & ldc ) {
     398istype & ?|?( istype & is, long double _Complex & ldc ) {
    399399        long double re, im;
    400400        fmt( is, "%Lf%Lfi", &re, &im );
     
    405405_Istream_cstrUC cstr( char * str ) { return (_Istream_cstrUC){ str }; }
    406406forall( dtype istype | istream( istype ) )
    407 istype * ?|?( istype * is, _Istream_cstrUC cstr ) {
     407istype & ?|?( istype & is, _Istream_cstrUC cstr ) {
    408408        fmt( is, "%s", cstr.s );
    409409        return is;
     
    412412_Istream_cstrC cstr( char * str, int size ) { return (_Istream_cstrC){ str, size }; }
    413413forall( dtype istype | istream( istype ) )
    414 istype * ?|?( istype * is, _Istream_cstrC cstr ) {
     414istype & ?|?( istype & is, _Istream_cstrC cstr ) {
    415415        char buf[16];
    416416        sprintf( buf, "%%%ds", cstr.size );
  • src/libcfa/rational

    r92494fd r09687aa  
    1212// Created On       : Wed Apr  6 17:56:25 2016
    1313// Last Modified By : Peter A. Buhr
    14 // Last Modified On : Wed Aug 23 22:35:09 2017
    15 // Update Count     : 95
     14// Last Modified On : Wed Dec  6 23:12:53 2017
     15// Update Count     : 97
    1616//
    1717
     
    135135// I/O
    136136forall( otype RationalImpl | arithmetic( RationalImpl ) )
    137 forall( dtype istype | istream( istype ) | { istype * ?|?( istype *, RationalImpl & ); } )
    138 istype * ?|?( istype *, Rational(RationalImpl) & );
     137forall( dtype istype | istream( istype ) | { istype & ?|?( istype &, RationalImpl & ); } )
     138istype & ?|?( istype &, Rational(RationalImpl) & );
    139139
    140140forall( otype RationalImpl | arithmetic( RationalImpl ) )
    141 forall( dtype ostype | ostream( ostype ) | { ostype * ?|?( ostype *, RationalImpl ); } )
    142 ostype * ?|?( ostype *, Rational(RationalImpl ) );
     141forall( dtype ostype | ostream( ostype ) | { ostype & ?|?( ostype &, RationalImpl ); } )
     142ostype & ?|?( ostype &, Rational(RationalImpl ) );
    143143
    144144// Local Variables: //
  • src/libcfa/rational.c

    r92494fd r09687aa  
    1010// Created On       : Wed Apr  6 17:54:28 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug 23 22:38:48 2017
    13 // Update Count     : 154
     12// Last Modified On : Wed Dec  6 23:13:58 2017
     13// Update Count     : 156
    1414//
    1515
     
    228228
    229229forall( otype RationalImpl | arithmetic( RationalImpl ) )
    230 forall( dtype istype | istream( istype ) | { istype * ?|?( istype *, RationalImpl & ); } )
    231 istype * ?|?( istype * is, Rational(RationalImpl) & r ) {
     230forall( dtype istype | istream( istype ) | { istype & ?|?( istype &, RationalImpl & ); } )
     231istype & ?|?( istype & is, Rational(RationalImpl) & r ) {
    232232        RationalImpl t;
    233233        is | r.numerator | r.denominator;
     
    239239
    240240forall( otype RationalImpl | arithmetic( RationalImpl ) )
    241 forall( dtype ostype | ostream( ostype ) | { ostype * ?|?( ostype *, RationalImpl ); } )
    242 ostype * ?|?( ostype * os, Rational(RationalImpl ) r ) {
     241forall( dtype ostype | ostream( ostype ) | { ostype & ?|?( ostype &, RationalImpl ); } )
     242ostype & ?|?( ostype & os, Rational(RationalImpl ) r ) {
    243243        return os | r.numerator | '/' | r.denominator;
    244244} // ?|?
Note: See TracChangeset for help on using the changeset viewer.