Skip to content

Commit 36bc907

Browse files
Added rfl::DefaultVal to the documentation
1 parent 192a74e commit 36bc907

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

docs/default_val.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,19 @@ Example (no field names / positional arrays):
4646
DefaultVal also works when using rfl::NoFieldNames (positional JSON arrays). Omitted positions that correspond to DefaultVal fields get their default values:
4747

4848
```cpp
49-
const auto homer = rfl::json::read<Person, rfl::NoFieldNames>(R"(["Homer"])" ).value();
49+
const auto homer = rfl::json::read<Person, rfl::NoFieldNames>(R"(["Homer"])").value();
5050
// homer.first_name == "Homer"
5151
// homer.last_name == "Simpson"
5252
// homer.town == ""
5353
```
5454

5555
## When to use
5656

57-
Use rfl::DefaultVal when you want a field to be optional at the input side but still available as a value on the resulting object (no std::optional or pointer indirection). It is particularly useful for fields with sensible defaults (for example, a common last name, a default configuration value, or empty containers/strings).
57+
Use `rfl::DefaultVal` when you want a field to be optional at the input side but still available as a value on the resulting object (no std::optional or pointer indirection). It is particularly useful for fields with sensible defaults (for example, a common last name, a default configuration value, or empty containers/strings).
5858

5959
## Notes
6060

6161
- The underlying type must be default-constructible to allow resetting via `rfl::Default` or when no explicit default is supplied.
62-
- DefaultVal preserves normal read/write semantics; other fields that are not DefaultVal remain required unless expressed as optionals or handled by processors (e.g., rfl::DefaultIfMissing).
62+
- DefaultVal preserves normal read/write semantics; other fields that are not DefaultVal remain required unless expressed as optionals or handled by processors (e.g., `rfl::DefaultIfMissing`).
6363

6464
For more advanced control over when fields are considered missing and how defaults are applied, see the processors documentation (e.g., `rfl::DefaultIfMissing`).

mkdocs.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ nav:
113113
- The basics:
114114
- Structs: concepts/structs.md
115115
- Optional fields: optional_fields.md
116+
- Default values: default_val.md
116117
- Struct flattening: flatten_structs.md
117118
- Processors: concepts/processors.md
118119
- The rfl::Field-syntax: concepts/field_syntax.md

0 commit comments

Comments
 (0)