bitwizeshift / bitwizeshift/bit-stl
Optimized `optional` type
- Dominant language
- C++
- Stars
- 9
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
C++17 introduces `optional` (of which, `bit::stl::optional` is based on for pre-c++17 support).
`optional` satisfies nullable stack values; however it does not play nice when used in composition, since the `bool` member pushes additional padding when used in arrays, or when a member immedately succeeds an `optional` member.
For this, there are two proposed types:
- `bit::stl::optional_array` -- an array of optional values that behaves like `std::array` where `value_type` is `T*` (with `nullptr` representing not-set). This would allow `N` optionals to be stored contiguously, with `N` `bool`s indicating their construction to also be contiguous.
- `bit::stl::optional_tuple` -- a `tuple` of values that may or may not contain a value. This is a generalization of `optional_array`, where each member may be a different type. The `bool`s indicating initialization is stored contiguously in memory, which optimizes storage.
Contributor guide
Assessment
This issue has not been assessed yet.