Repository navigation
docs: rewrite Chapter 07 — Enums from C++98 to C++26 - #14
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Escaped Markdown delimiters break code-example rendering throughout the chapter.
3 open issues
What changed in this PR
Rewrites Chapter 07 as a narrative guide to enums from C++98 through C++26, connecting language rules to the course’s examples.
Changes:
- Expands coverage of conversions, validation, bitmasks, ABI, and reflection.
- Replaces an undefined conversion with a safe unnamed-value example.
- Corrects opaque-enum completeness explanations and adds a compile-time assertion.
| File | Description |
|---|---|
01_low_level/07_enums/README.md |
Rewrites and expands the enums chapter. |
01_low_level/07_enums/02_enums_scoped/enums_scoped.cpp |
Corrects completeness comments and asserts enum size. |
01_low_level/07_enums/01_enums_core/enums_core.cpp |
Demonstrates a safe, in-range unnamed enum value. |
Review effort: Balanced
|
|
||
| Consider status and device-state values that happen to share their representation. There is no implicit assignment from one enum type to another, and this is intentional: the number alone does not define its meaning. | ||
|
|
||
| \`\`\`cpp |
Contributor
There was a problem hiding this comment.
Removed the backslashes from the Markdown code and inline-code delimiters and repaired the enum class delimiter. Commit: 502defd.
|
|
||
| ### Never use an out-of-range example as a harmless demonstration | ||
|
|
||
| The existing \`01_enums_core/enums_core.cpp\` example casts \`20\` to an enum whose enumerators are only \`0\` and \`1\`. Because that enum has no fixed underlying type, it is not a valid demonstration of merely holding an unnamed enum value. It needs correction in the accompanying source example as well as in this chapter. |
Contributor
There was a problem hiding this comment.
Updated the paragraph to describe the in-range unnamed value 3 in the corrected example and noted that the out-of-range cast remains only in a warning comment. Commit: 502defd.
Co-authored-by: yuchdev <678436+yuchdev@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Rewrite the enums chapter in the narrative technical-literature format used in Chapters 01–06, covering classic unscoped enums through C++26 static reflection.
Correctness fixes
int) and completeness of opaque enum declarations.Expanded coverage
using enum, C++23std::to_underlyingandstd::is_scoped_enum.std::meta::enumerators_ofwith availability caveats.Scope and validation
Changes only Chapter 07 README and two directly associated examples. Structurally checked the required ending order and code-fence balance. C++26 reflection example is illustrative and uncompiled; CI should validate the repository's C++20 baseline.