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