source:
tests/poly-d-cycle.cfa@
9e18677
| Last change on this file since 9e18677 was 91131689, checked in by , 5 years ago | |
|---|---|
|
|
| File size: 474 bytes | |
| Rev | Line | |
|---|---|---|
| [91131689] | 1 | // Check that a cycle of polymorphic dtype structures can be instancated. |
| [3f06c05] | 2 | |
| 3 | #include <stdio.h> | |
| 4 | ||
| [91131689] | 5 | forall(dtype T) |
| [3f06c05] | 6 | struct func_table; |
| 7 | ||
| [91131689] | 8 | forall(dtype U) |
| [3f06c05] | 9 | struct object { |
| 10 | func_table(U) * virtual_table; | |
| 11 | }; | |
| 12 | ||
| [91131689] | 13 | forall(dtype T) |
| [3f06c05] | 14 | struct func_table { |
| 15 | void (*object_func)(object(T) *); | |
| 16 | }; | |
| 17 | ||
| 18 | void func(object(int) *) { | |
| 19 | printf("Success!\n"); | |
| 20 | } | |
| 21 | ||
| 22 | func_table(int) an_instance = { func }; | |
| 23 | ||
| 24 | int main(int argc, char * argv[]) { | |
| 25 | object(int) x = { 0p }; | |
| 26 | an_instance.object_func( &x ); | |
| 27 | return 0; | |
| 28 | } |
Note:
See TracBrowser
for help on using the repository browser.