Clarified use of unions in C++.

Change-Id: I9654e0c6a45457c8e150f07dd5f7b39539266f9e
This commit is contained in:
Wouter van Oortmerssen
2015-09-14 11:00:12 -07:00
parent 5db12e9907
commit af1487bcfb
3 changed files with 18 additions and 3 deletions

View File

@@ -72,7 +72,9 @@ since they won't bloat up the buffer sizes if they're not actually used.
We do something similarly for the union field `test` by specifying a `0` offset
and the `NONE` enum value (part of every union) to indicate we don't actually
want to write this field. You can use `0` also as a default for other
non-scalar types, such as strings, vectors and tables.
non-scalar types, such as strings, vectors and tables. To pass an actual
table, pass a preconstructed table as `mytable.Union()` that corresponds to
union enum you're passing.
Tables (like `Monster`) give you full flexibility on what fields you write
(unlike `Vec3`, which always has all fields set because it is a `struct`).