• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

steve-downey / sandbox-expected / 28965523762

07 Jul 2026 12:30PM UTC coverage: 97.017% (+6.8%) from 90.196%
28965523762

push

github

web-flow
Expected over references (#61)

## Expected over References — Implementation of D4280R0

### Summary

Implements four partial specializations of `beman::expected` that allow
reference types as `T` and/or `E`, as proposed in [D4280R0 (Expected
over References)](https://wg21.link/D4280R0):

| Specialization | Storage | Step |
|---|---|---|
| `expected<T&, E>` | `T*` + `union { E }` + bool | 7 |
| `expected<T, E&>` | `union { T }` + `E*` + bool | 8 |
| `expected<T&, E&>` | `T*` + `E*` + bool | 9 |
| `expected<void, E&>` | `E*` + bool | 10 |

This is a reordered, cleaned-up replay of `expected-over-references`
(see that branch's own PR for the original messy history) — the final
code/tests/docs are the same feature, restructured so `unexpected<E&>`
is specialized first and the error-reference axis collapses into the
primary/void templates from the start, instead of building and later
discarding three separate reference-error specializations.

On top of that replay, this branch is merged with `main`'s new
std::expected parity test harness (parameterizes the behavioral test
suite to run against both `beman::expected` and `std::expected`),
resolving the merge conflict between the two and fixing two
toolchain-specific issues that surfaced running the merged suite in CI
(see `docs/std-parity.md`):

- A `[[nodiscard]]`-discard warning under `-Werror`.
- A libc++ cross-specialization friend-access bug in heterogeneous
`std::unexpected` comparison (guarded out for `std::expected`, not a
beman defect).

The std::expected parity target (`.std`) is also skipped entirely on
libc++ — libc++ has independent bugs of its own in this exact area (see
`docs/std-parity.md`) that aren't worth chasing; it continues to run
normally under gcc/libstdc++ and clang-with-libstdc++.

**CI:** full matrix green (gcc 13–16, clang 19–22, appleclang, libstdc++
and libc++, multiple sanitizer/Werror/coverage/modules configurations).

### Design decisions

All four specializations follow the... (continued)

683 of 704 relevant lines covered (97.02%)

25.96 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.12
/include/beman/expected/expected.hpp


Source Not Available

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc