Changeset fd54fef for libcfa/src/iostream.cfa
- Timestamp:
- Jan 19, 2021, 8:44:29 PM (3 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- dafbde8
- Parents:
- 2f47ea4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/iostream.cfa
r2f47ea4 rfd54fef 36 36 37 37 38 forall( dtype ostype| ostream( ostype ) ) {38 forall( ostype & | ostream( ostype ) ) { 39 39 ostype & ?|?( ostype & os, bool b ) { 40 40 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); … … 402 402 403 403 // tuples 404 forall( dtype ostype, otype T, ttype Params| writeable( T, ostype ) | { ostype & ?|?( ostype &, Params ); } ) {404 forall( ostype &, T, Params... | writeable( T, ostype ) | { ostype & ?|?( ostype &, Params ); } ) { 405 405 ostype & ?|?( ostype & os, T arg, Params rest ) { 406 406 (ostype &)(os | arg); // print first argument … … 421 421 422 422 // writes the range [begin, end) to the given stream 423 forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otypeiterator_type | iterator( iterator_type, elt_type ) ) {423 forall( ostype &, elt_type | writeable( elt_type, ostype ), iterator_type | iterator( iterator_type, elt_type ) ) { 424 424 void write( iterator_type begin, iterator_type end, ostype & os ) { 425 425 void print( elt_type i ) { os | i; } … … 442 442 // Default prefix for non-decimal prints is 0b, 0, 0x. 443 443 #define IntegralFMTImpl( T, IFMTNP, IFMTP ) \ 444 forall( dtype ostype| ostream( ostype ) ) { \444 forall( ostype & | ostream( ostype ) ) { \ 445 445 ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \ 446 446 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); \ … … 535 535 // Default prefix for non-decimal prints is 0b, 0, 0x. 536 536 #define IntegralFMTImpl128( T, SIGNED, CODE, IFMTNP, IFMTP ) \ 537 forall( dtype ostype| ostream( ostype ) ) \537 forall( ostype & | ostream( ostype ) ) \ 538 538 static void base10_128( ostype & os, _Ostream_Manip(T) f ) { \ 539 539 if ( f.val > UINT64_MAX ) { \ … … 552 552 } /* if */ \ 553 553 } /* base10_128 */ \ 554 forall( dtype ostype| ostream( ostype ) ) { \554 forall( ostype & | ostream( ostype ) ) { \ 555 555 ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \ 556 556 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); \ … … 654 654 #if defined( __SIZEOF_INT128__ ) 655 655 // Default prefix for non-decimal prints is 0b, 0, 0x. 656 forall( dtype ostype| ostream( ostype ) )656 forall( ostype & | ostream( ostype ) ) 657 657 static inline void base_128( ostype & os, unsigned int128 val, unsigned int128 power, _Ostream_Manip(uint64_t) & f, unsigned int maxdig, unsigned int bits, unsigned int cnt = 0 ) { 658 658 int wd = 1; // f.wd is never 0 because 0 implies left-pad … … 719 719 720 720 #define IntegralFMTImpl128( T ) \ 721 forall( dtype ostype| ostream( ostype ) ) { \721 forall( ostype & | ostream( ostype ) ) { \ 722 722 ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \ 723 723 _Ostream_Manip(uint64_t) fmt; \ … … 767 767 768 768 #define FloatingPointFMTImpl( T, DFMTNP, DFMTP ) \ 769 forall( dtype ostype| ostream( ostype ) ) { \769 forall( ostype & | ostream( ostype ) ) { \ 770 770 ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \ 771 771 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); \ … … 801 801 // *********************************** character *********************************** 802 802 803 forall( dtype ostype| ostream( ostype ) ) {803 forall( ostype & | ostream( ostype ) ) { 804 804 ostype & ?|?( ostype & os, _Ostream_Manip(char) f ) { 805 805 if ( f.base != 'c' ) { // bespoke binary/octal/hex format … … 834 834 // *********************************** C string *********************************** 835 835 836 forall( dtype ostype| ostream( ostype ) ) {836 forall( ostype & | ostream( ostype ) ) { 837 837 ostype & ?|?( ostype & os, _Ostream_Manip(const char *) f ) { 838 838 if ( ! f.val ) return os; // null pointer ? … … 882 882 883 883 884 forall( dtype istype| istream( istype ) ) {884 forall( istype & | istream( istype ) ) { 885 885 istype & ?|?( istype & is, bool & b ) { 886 886 char val[6]; … … 1048 1048 // *********************************** manipulators *********************************** 1049 1049 1050 forall( dtype istype| istream( istype ) )1050 forall( istype & | istream( istype ) ) 1051 1051 istype & ?|?( istype & is, _Istream_Cstr f ) { 1052 1052 // skip xxx … … 1083 1083 } // ?|? 1084 1084 1085 forall( dtype istype| istream( istype ) )1085 forall( istype & | istream( istype ) ) 1086 1086 istype & ?|?( istype & is, _Istream_Char f ) { 1087 1087 fmt( is, "%*c" ); // argument variable unused … … 1090 1090 1091 1091 #define InputFMTImpl( T, CODE ) \ 1092 forall( dtype istype| istream( istype ) ) \1092 forall( istype & | istream( istype ) ) \ 1093 1093 istype & ?|?( istype & is, _Istream_Manip(T) f ) { \ 1094 1094 enum { size = 16 }; \ … … 1119 1119 InputFMTImpl( long double, "Lf" ) 1120 1120 1121 forall( dtype istype| istream( istype ) )1121 forall( istype & | istream( istype ) ) 1122 1122 istype & ?|?( istype & is, _Istream_Manip(float _Complex) fc ) { 1123 1123 float re, im; … … 1130 1130 } // ?|? 1131 1131 1132 forall( dtype istype| istream( istype ) )1132 forall( istype & | istream( istype ) ) 1133 1133 istype & ?|?( istype & is, _Istream_Manip(double _Complex) dc ) { 1134 1134 double re, im; … … 1141 1141 } // ?|? 1142 1142 1143 forall( dtype istype| istream( istype ) )1143 forall( istype & | istream( istype ) ) 1144 1144 istype & ?|?( istype & is, _Istream_Manip(long double _Complex) ldc ) { 1145 1145 long double re, im;
Note: See TracChangeset
for help on using the changeset viewer.