|
20 | 20 | // Tag discriminator tag to store for each object (uintNN_t where |
21 | 21 | // NN is large enough to hold the #alternatives in the union) |
22 | 22 | // |
23 | | -// For an object U of union type, when inject a call to this (zero-based alternative #s) |
24 | | -// U is created initialized on_set_alternative(&U,0) = the first alternative# is active |
25 | | -// U is created uninitialized on_set_alternative(&U,invalid) |
26 | | -// U.A = xxx (alt #A is assigned to) on_set_alternative(&U,A) |
27 | | -// U.A (alt #A is otherwise mentioned) on_get_alternative(&U,A) |
28 | | -// U is destroyed / goes out of scope on_destroy(&U) |
| 23 | +// For an object U of union type that |
| 24 | +// has a unique address, when inject a call to this (zero-based alternative #s) |
| 25 | +// |
| 26 | +// U is created initialized on_set_alternative(&U,0) = the first alternative# is active |
| 27 | +// |
| 28 | +// U is created uninitialized on_set_alternative(&U,invalid) |
| 29 | +// |
| 30 | +// U.A = xxx (alt #A is assigned to) on_set_alternative(&U,#A) |
| 31 | +// |
| 32 | +// U.A (alt #A is otherwise mentioned) on_get_alternative(&U,#A) |
| 33 | +// and A is not a common initial |
| 34 | +// sequence |
| 35 | +// |
| 36 | +// U is destroyed / goes out of scope on_destroy(&U) |
29 | 37 | // |
30 | 38 | // That's it. Here's an example: |
31 | 39 | // { |
32 | 40 | // union Test { int a; double b; }; |
33 | | -// Test t = {42}; union_registry<>::on_set_alternative(&u,0); |
34 | | -// std::cout << t.a; union_registry<>::on_get_alternative(&u,0); |
35 | | -// t.b = 3.14159; union_registry<>::on_set_alternative(&u,1); |
36 | | -// std::cout << t.b; union_registry<>::on_get_alternative(&u,1); |
37 | | -// } union_registry<>::on_destroy(&u); |
| 41 | +// Test t = {42}; union_registry<>::on_set_alternative(&u,0); |
| 42 | +// std::cout << t.a; union_registry<>::on_get_alternative(&u,0); |
| 43 | +// t.b = 3.14159; union_registry<>::on_set_alternative(&u,1); |
| 44 | +// std::cout << t.b; union_registry<>::on_get_alternative(&u,1); |
| 45 | +// } union_registry<>::on_destroy(&u); |
38 | 46 | // |
39 | 47 | // For all unions with under 256 alternatives, use union_registry<> |
40 | 48 | // For all unions with between 256 and 16k alternatives, use union_registry<uint16_t> |
|
0 commit comments