Skip to content

docs(cpp11): add STL real-world case and exercise mapping for 16-generalized-unions#57

Open
lczllx wants to merge 2 commits into
mcpp-community:mainfrom
lczllx:docs/cpp11-16-generalized-unions-book
Open

docs(cpp11): add STL real-world case and exercise mapping for 16-generalized-unions#57
lczllx wants to merge 2 commits into
mcpp-community:mainfrom
lczllx:docs/cpp11-16-generalized-unions-book

Conversation

@lczllx

@lczllx lczllx commented Jun 11, 2026

Copy link
Copy Markdown

docs(cpp11): add STL real-world case and exercise mapping for 16-generalized-unions

  • add section 二 真实案例 — include std::variant Variant_storage and
    std::any _Storage_t examples, both cited from vendored msvc-stl/

  • fill in 四 练习代码 — exercise descriptions, file links and
    d2x checker command

  • fix empty Code link in header table

Case selection notes:
Picked Variant_storage over std::optional _Optional_destruct_base
because the variant recursive union demonstrates both key C++11
generalized-union capabilities — non-trivial members and manual
destructor management — while the optional pattern is effectively
a special case of variant. std::any adds a second typical use:
union as type-erased storage. Both are directly traceable in the
vendored msvc-stl/, consistent with how ch00 cites xutility.

lczllx added 2 commits June 11, 2026 21:50
…ralized-unions

- add section 二 真实案例 — include std::variant _Variant_storage_ and
  std::any _Storage_t examples, both cited from vendored msvc-stl/

- fill in 四 练习代码 — exercise descriptions, file links and
  d2x checker command

- fix empty Code link in header table

Case selection notes:
  Picked _Variant_storage_ over std::optional _Optional_destruct_base
  because the variant recursive union demonstrates both key C++11
  generalized-union capabilities — non-trivial members and manual
  destructor management — while the optional pattern is effectively
  a special case of variant. std::any adds a second typical use:
  union as type-erased storage. Both are directly traceable in the
  vendored msvc-stl/, consistent with how ch00 cites xutility.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant