- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/array-collections/array-raii-cfa.cfa
r1665ee5 rcfbc56ec 16 16 // CFA array means like `array(float, 17) x;` 17 17 18 19 #include <fstream.hfa>20 18 #include <collections/array.hfa> 21 19 … … 24 22 25 23 #include "array-raii.hfa" 26 27 void test_uninit_alt() {28 printf(" [1]\n");29 {30 array(thing, 5) a = { delay_init };31 printf("before ctors\n");32 for(i; 5) {33 if (i == 1)34 (a[i]){}; // no need for `emplace` bc no-arg ctor call means elem's real ctor35 else if (i == 2)36 (a[i]){888};37 else38 (a[i]){i};39 }40 for(i; 5) printf("func %d\n", a[i].mem);41 }42 printf(" [2]\n");43 {44 array(thing, 2, 3) a = { delay_init };45 printf("before ctors\n");46 for(i; 2) for(j; 3) {47 if (i == 1 && j == 1)48 (a[i][j]){};49 else if (i == 1 && j == 2)50 (a[i][j]){888};51 else52 (a[i][j]){100 + 10 * i + j};53 }54 for(i; 2) for(j; 3) {55 printf("func %d at (%d, %d)\n", a[i][j].mem, i, j);56 }57 }58 }59 60 void test_uCxxCheatSheet() {61 struct S {62 int i;63 };64 void ?{}( S & s, int i ) { s.i = i; sout | "ctor" | s.i; }65 void ^?{}( S & s ) { sout | "dtor" | s.i; }66 // int main() {67 enum { N = 5 };68 array(S, N) s = { delay_init }; // no constructor calls69 for ( i; N ) s[i]{ i };70 for ( i; N ) sout | s[i].i;71 // }72 }73 74 void test_extras() {75 76 printf("=== uninit alt ( uArray )\n");77 test_uninit_alt();78 79 printf("=== uC++ cheat sheet\n");80 test_uCxxCheatSheet();81 }
Note: See TracChangeset
for help on using the changeset viewer.