- Timestamp:
- Oct 20, 2023, 9:37:11 AM (10 months ago)
- Branches:
- master
- Children:
- 278e162, 7b84d3e
- Parents:
- 7619400
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/genericUnion.cfa
r7619400 rabb04a4 10 10 // Created On : Tue Dec 25 14:42:46 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Dec 25 14:46:33 201813 // Update Count : 212 // Last Modified On : Fri Oct 20 09:13:26 2023 13 // Update Count : 15 14 14 // 15 15 16 #include <fstream.hfa> 16 17 #include <limits.hfa> 17 18 18 forall( T)19 forall( T ) 19 20 union ByteView { 20 21 T val; … … 23 24 24 25 forall(T) 25 void print( ByteView(T) x) {26 for ( int i = 0; i < sizeof(int); i++) {// want to change to sizeof(T)27 printf("%02x", x.bytes[i] & 0xff);26 void print( ByteView(T) x ) { 27 for ( i; sizeof(int) ) { // want to change to sizeof(T) 28 sout | nobase( pad0( wd( 2, hex( x.bytes[i] & 0xff ) ) ) ) | nosep; 28 29 } 29 30 } 30 31 31 32 forall(T) 32 void f( ByteView(T) x, T val) {33 print( x);34 printf(" ");33 void f( ByteView(T) x, T val ) { 34 print( x ); 35 sout | " "; 35 36 x.val = val; 36 print( x);37 printf("\n");37 print( x ); 38 sout | nl; 38 39 } 39 40 40 41 int main() { 42 sout | nlOff; 41 43 ByteView(unsigned) u = { 0 }; 42 44 ByteView(int) i = { 0 }; 43 f( u, MAX);44 f( i, -1);45 f( u, MAX ); 46 f( i, -1 ); 45 47 } 46 48
Note: See TracChangeset
for help on using the changeset viewer.