diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml
index 17f36523..11b48fd1 100644
--- a/.github/workflows/ci_tests.yml
+++ b/.github/workflows/ci_tests.yml
@@ -29,7 +29,9 @@ jobs:
{"preset": "llvm-debug", "image": "ghcr.io/bemanproject/infra-containers-clang:latest"},
{"preset": "llvm-release", "image": "ghcr.io/bemanproject/infra-containers-clang:latest"},
{"preset": "appleclang-debug", "runner": "macos-latest"},
- {"preset": "appleclang-release", "runner": "macos-latest"}
+ {"preset": "appleclang-release", "runner": "macos-latest"},
+ {"preset": "msvc-debug", "runner": "windows-latest"},
+ {"preset": "msvc-release", "runner": "windows-latest"}
]
build-and-test:
@@ -138,6 +140,22 @@ jobs:
}
]
}
+ ],
+ "msvc": [
+ { "versions": ["latest"],
+ "tests": [
+ { "cxxversions": ["c++23"],
+ "tests": [
+ { "stdlibs": ["stl"],
+ "tests": [
+ "Debug.Default", "Release.Default", "Release.MaxSan",
+ "Debug.-DBEMAN_EXPECTED_USE_MODULES=On"
+ ]
+ }
+ ]
+ }
+ ]
+ }
]
}
diff --git a/CMakePresets.json b/CMakePresets.json
index 08a4cb40..89b34361 100644
--- a/CMakePresets.json
+++ b/CMakePresets.json
@@ -145,7 +145,8 @@
"_debug-base"
],
"cacheVariables": {
- "CMAKE_TOOLCHAIN_FILE": "${sourceDir}/infra/cmake/msvc-toolchain.cmake"
+ "CMAKE_TOOLCHAIN_FILE": "${sourceDir}/infra/cmake/msvc-toolchain.cmake",
+ "CMAKE_CXX_STANDARD": "23"
},
"condition": {
"type": "equals",
@@ -161,7 +162,8 @@
"_release-base"
],
"cacheVariables": {
- "CMAKE_TOOLCHAIN_FILE": "${sourceDir}/infra/cmake/msvc-toolchain.cmake"
+ "CMAKE_TOOLCHAIN_FILE": "${sourceDir}/infra/cmake/msvc-toolchain.cmake",
+ "CMAKE_CXX_STANDARD": "23"
},
"condition": {
"type": "equals",
diff --git a/Makefile b/Makefile
index ac3a0e08..4183230a 100755
--- a/Makefile
+++ b/Makefile
@@ -196,7 +196,12 @@ WORDING_DIR := papers/wording
WORDING_FRAGMENTS := \
$(addprefix $(WORDING_DIR)/fragments/,$(addsuffix .tex,$(WORDING_CLAUSES)))
-SPECGEN_CLANG_ARGS := -std=c++2c -Iinclude
+# The wording shows the standard's expansion of a configuration macro, not
+# whichever one the standard library specgen's Clang finds happens to give:
+# BEMAN_EXPECTED_CONSTEXPR_EXCEPTION is `constexpr` in the draft, which is
+# what this feature-test macro selects. The value is libstdc++ 16's.
+SPECGEN_CLANG_ARGS := -std=c++2c -Iinclude \
+ -D__cpp_lib_constexpr_exceptions=202502L
ifneq ($(SPECGEN_GCC_TOOLCHAIN),)
SPECGEN_CLANG_ARGS += --gcc-toolchain=$(SPECGEN_GCC_TOOLCHAIN)
endif
diff --git a/README.md b/README.md
index 069b08cf..fe38e787 100644
--- a/README.md
+++ b/README.md
@@ -65,18 +65,20 @@ builtin lands in **GCC 13** and **Clang 19**, which sets the floor:
* **GCC ≤ 12 / Clang ≤ 17** lack the builtin, so the trait is undefined in C++20
mode.
-* **Clang 18** has the builtin but rejects out-of-line definitions of constrained
- members whose `requires`-clause names the enclosing `expected<…>` type (or a
- member typedef) with a spelling that differs from the in-class declaration —
- GCC and Clang 19+ canonicalize these, Clang 18 does not.
+* **Clang 18** has the builtin. It rejects an out-of-line definition of a
+ constrained member whose `requires`-clause names the enclosing `expected<…>`
+ type (or a member typedef) with a spelling that differs from the in-class
+ declaration — GCC and Clang 19+ canonicalize these, Clang 18 does not. Each
+ such definition is therefore spelled exactly as its declaration, and Clang 18
+ accepts the header; it is not in the CI matrix.
**MSVC is not currently supported.** In C++23 the trait is available, but MSVC
applies the same out-of-line-definition constraint-matching strictness as Clang
18 (`C2244: unable to match function definition to an existing declaration`).
-The fix is to make each such member's definition token-identical to its
-declaration; that work is not done here simply because we do not have direct
-MSVC access to develop and verify the workarounds. Contributions with MSVC
-access are welcome.
+The four definitions MSVC 19.52 rejected for this are now token-identical to
+their declarations, checked with Clang 18, which rejected the same four. We do
+not have direct MSVC access, so the MSVC jobs in CI, which build and test at
+C++23, are the only verification. Contributions with MSVC access are welcome.
The Windows setup below is retained for contributors who want to investigate
MSVC support. It is currently unsupported and unverified; the documented build
diff --git a/docs/plan/specgen-catchup.md b/docs/plan/specgen-catchup.md
index 0de815a6..e8f5f834 100644
--- a/docs/plan/specgen-catchup.md
+++ b/docs/plan/specgen-catchup.md
@@ -25,7 +25,13 @@ done as far as it can go. What is left of it waits on
[reference-error-overloads](#reference-error-overloads) and on specgen, and
[validation-findings](#validation-findings) and
[exposition-helpers](#exposition-helpers) wait with it.
-[macro-specifiers](#macro-specifiers) waits on specgen#377.
+On the branch `specgen-0.58` (from `upstream/main` at `54bd02e`, 2026-11-30):
+the wording regenerated with specgen 0.58.0, and
+[macro-specifiers](#macro-specifiers) and
+[implementation-extras](#implementation-extras) done, now that every
+specgen request this plan waited on is closed, and
+[derived-let](#derived-let) carried out. What else that unblocks is
+in the [specgen-pin](#specgen-pin) Log entry for the day.
---
@@ -505,6 +511,13 @@ prevents: that is
stage waits for it. Check: the macro appears 0 times in the wording, and
`[expected.bad.void]` is left with the `= default` marks alone.
+Done on `specgen-0.58` (2026-11-30), with specgen 0.58.0: `SPECGEN_CLANG_ARGS`
+defines `__cpp_lib_constexpr_exceptions=202502L`, as
+[macro-expansion-args](#macro-expansion-args) recommends, and the header is
+unchanged. The macro appears 0 times; against the draft at n5054,
+`[expected.bad.void]` is 8 / 0, the `= default`s, and `[expected.bad]` 1 / 0,
+the parameter name.
+
### Stage 8 — [member-routing](#member-routing)
Replace the banner comments with `// \ref{stable.name}, title` group
@@ -585,6 +598,14 @@ Not done, and why:
`bad_expected_access` match the draft's, which waits on specgen#377 and
specgen#385.
+2026-11-30, with specgen 0.58.0: the deduction guide is in `unexpected`'s
+synopsis (specgen#384) and "Assignment rebinds" opens `[expected.ref.assign]`
+(specgen#383), with no change to the headers. specgen#385 covers the
+`noexcept` and `= default` cases, done under
+[implementation-extras](#implementation-extras); a parameter name in the
+synopsis has no marker yet. `[expected.bad.void]`'s synopsis is now the
+draft's, so its copy in [draft-text-copies](#draft-text-copies) can go.
+
### Stage 10 — [class-prose](#class-prose)
Rewrite the general subclauses as the draft has them: unlabelled paragraphs
@@ -901,6 +922,10 @@ draft diff is the check that the class agrees with the standard.
- 2026-11-19: the one in `expected.hpp` is gone, replaced by the source of
`[expected.syn]` (`ad9ca81`). The two in `bad_expected_access.hpp` stay
until the generated synopses there match the draft's.
+- 2026-11-30: `[expected.bad.void]` has no marks against n5054, so its copy
+ is gone, on `specgen-0.58`, with Steve Downey's agreement. The
+ `[expected.bad]` copy stays until the synopsis drops the constructor's
+ parameter name, which no marker does yet.
### clause-order
@@ -967,13 +992,21 @@ spelling, of the kind specgen#282 settled for `= delete`.
constructors and copy assignment operators of the three `expected`
classes, which the library declares `noexcept(...)` and the draft does
not. Nothing is changed in the headers until specgen has a marker.
+- 2026-11-30: specgen#385 gave `\omit noexcept` and `\omit default`. On
+ `specgen-0.58`, `\omit noexcept` on `unexpected`'s three constructors,
+ `expected`'s default constructor, and the copy constructors and copy
+ assignment operators of `expected` and `expected`;
+ `\omit default` on `bad_expected_access`'s six special members.
+ `[expected.bad.void]` has no marks against n5054, and
+ `[expected.unexpected]` is 10 / 3, from 16 / 7. The parameter name has
+ no marker; it is the third case of specgen#385, which closed without it.
### macro-expansion-args
**Question.** Which expansion of a configuration macro does the wording
show, and where does the build say so?
-**Status.** OPEN
-**Recommendation.** The expansion the standard has: `constexpr`, by adding
+**Status.** DECIDED
+**Decision.** The expansion the standard has: `constexpr`, by adding
`-D__cpp_lib_constexpr_exceptions=202502L` to `SPECGEN_CLANG_ARGS`.
**Why.** specgen writes what the macro expands to in the translation unit it
parses, so the wording follows whichever standard library and compiler
@@ -983,9 +1016,15 @@ it. Stating the macro on the command line makes the render the same on every
machine, and the value is the one libstdc++ 16 defines. The cost is that the
wording run and a real build may then parse the header differently, which is
what the option is for.
+**Decided by.** Steve Downey, 2026-11-30.
**Log.**
- 2026-11-19: opened. With the define and the `#undef` removed, on scratch,
the macro appears 0 times and `constexpr` stands in its place.
+- 2026-11-30: specgen#377 reads the `#undef`ed macro, so the define alone
+ does it. Carried out on `specgen-0.58` for
+ [macro-specifiers](#macro-specifiers), as recommended; still OPEN for the
+ ruling.
+- 2026-11-30: decided as recommended.
### unchanged-wording-source
@@ -1163,6 +1202,159 @@ headers by design, deferring to the primary template, and that belongs to
**Log.**
- 2026-11-19: opened, in carrying out [synopsis-shape](#synopsis-shape).
+### derived-let
+
+**Question.** The monadic operations name a type `U` or `G`. Now that
+specgen derives the draft's leading "Let `U` be ..." from the body's
+alias, how do the docblocks and the alias divide the work?
+**Status.** DECIDED
+**Decision.** The alias is spelled as the draft binds it, with
+`decltype((val_))` and `decltype(std::move(val_))` (`error()` for `G`), and
+the derived paragraph is the binding. Where the draft's spelling names a
+different type from the code's, the code's stays:
+[rvalue-error-binding](#rvalue-error-binding). The authored *Mandates* name `U` in the
+draft's words, and the trailing "where `U` is ..." in *Effects* goes.
+**Why.** The 21 derived paragraphs say each binding a second time beside the
+docblock's own. And the alias is read from one overload: for the `&` and
+`const&` pair it says `invoke_result_t`, which is wrong for `const&`.
+`decltype((val_))` is the same type in each body and is the draft's text.
+Using `U` in *Mandates* also lets `--validate` match the authored
+`is_same_v` conjunct with the derived one.
+**Decided by.** Steve Downey, 2026-11-30: take the recommendation.
+**Log.**
+- 2026-11-30: opened. Tried on the lvalue `and_then` of the primary template
+ on `specgen-0.58`: the item reads as `[expected.object.monadic]` does but
+ for the equivalent-to code block, one note fewer, and the tests pass. The
+ other 20 are left. In `[expected.ref.monadic]` the paper is the only text,
+ and `val_` is a `T*` there, so the binding is `decltype(*val_)` or `T&`,
+ which is the same type for every overload.
+- 2026-11-30: decided, and carried out on `specgen-0.58` for the 18
+ derived bindings left: the monadic operations of all three classes and
+ `value_or` of `expected`. 19 were derived; the other two of the
+ 21 counted are authored "Let `r`" sentences. `U` in
+ `expected` stays `T&`. `transform` and `transform_error` called
+ the result type `U` and the error type `G2`, against the derived
+ binding; they now use the draft's names, with an authored "Let" for
+ `transform`, whose assertions are not leading. 105 notes, from 110.
+ Carrying it out found that the recommendation's `error()` is wrong for
+ the rvalue overloads when `E` is a reference, so those twelve aliases,
+ four in each class, keep
+ `E&&`: [rvalue-error-binding](#rvalue-error-binding).
+
+### rvalue-error-binding
+
+**Question.** The rvalue overloads of `or_else` and `transform_error` bind
+`G` from the error as an rvalue. When `E` is a reference, what type is
+that?
+**Status.** DECIDED
+**Decision.** The type of `std::move(unex).error()`: the held
+`unexpected` is moved and then asked for the error. That is `E&&` for an
+object `E` and `E&` for a reference `E`. The same expression replaces
+`std::move(error())` wherever the wording has an rvalue error, not only in
+the binding of `G`. Not `std::move(*this).error()`, which has the same type
+but has an object declare itself expiring.
+**Why.** For `E` = `X&`, `error() &&` returns `E&&`, which collapses to `X&`,
+and the body passes `std::move(unex_).error()`, which is `X&` too, so the
+alias `E&&` is exact. The draft's spelling, `decltype(std::move(error()))`,
+is `X&&`: written into the alias it would compute a different `G`, and a
+callable taking `X&` would stop compiling. So the derived paragraph says
+`invoke_result_t`, which is right for `&&` but reads `E&&` for the
+`const&&` overload it also covers. The same spelling in the authored
+*Constraints* of the rvalue `and_then` and `transform`,
+`is_constructible_v`, misstates the
+code's `is_constructible_v` for a reference `E`. Both belong with
+[reference-error-overloads](#reference-error-overloads): the paper's
+wording does not yet say what a reference `E` does here. A spelling that
+is exact for both overloads is `decltype(std::move(*this).error())`.
+**Decided by.** Steve Downey, 2026-11-30.
+**Log.**
+- 2026-11-30: opened, from [derived-let](#derived-let).
+- 2026-11-30: reviewed, at Steve Downey's prompting that this is the
+ `boost::optional` steal. It is, and the paper already rules on it:
+ D4280's section on shallow conversions makes move-the-wrapper-then-access
+ a guarantee and names `std::move(r).error()` as the form. The code
+ follows it everywhere: no `std::move` is applied to an error or value
+ access outside a `decltype` in a non-reference branch. The wording does
+ not: `std::move(error())` is in 26 places in the docblocks, 23 in
+ `expected-new.tex`. For a reference `E` they are, by use: 3 `error_or`
+ *Returns* and 3 `value()` *Throws*, where the library itself would
+ initialize an object from the referent as an rvalue; 7 in the rvalue
+ `or_else` and `transform_error`, which hand the callable an rvalue; 6
+ `and_then` and `transform` *Effects*, `U(unexpect, std::move(error()))`,
+ ill-formed for any reference `E`, by constructibility for `X&` and by
+ the deleted `unexpect_t` overload for `const X&`; and 7 *Constraints* and
+ *Mandates*, false for `X&`, where the code keeps the overload, and true
+ for `const X&`. A scratch program checked each against the code with a
+ type that records being moved from: nothing is, in all three classes.
+ The tests assert that for the conversions only; the rvalue `error_or`,
+ `value()` and monadic operations on a reference `E` have no such test.
+ The same-type move constructor and assignment also write
+ `std::move(rhs.error())`, 3 places, and are covered by the rebinding
+ paragraph. The working draft made the same repair to `optional`: its
+ converting constructor from `optional&&` reads
+ `std::move(rhs).operator*()`. Still OPEN: the spelling is
+ `std::move(*this).error()` or `std::move(unex).error()`, which the
+ docblock of `error() &&` already uses.
+- 2026-11-30: decided, and carried out on `specgen-0.58`. `unex` is in
+ scope wherever it is needed: all three classes declare
+ `unexpected unex`, in the headers and in `expected-new.tex`, and the
+ draft names an exposition-only member inside `decltype` in the same
+ positions, as `decltype(std::move(val))`. In the code the twelve aliases
+ and the two assertions of `value() &&` are in function bodies. The one
+ place `unex_` cannot be named is a leading requires-clause, and those
+ keep `E&&`, which is exact there because each overload has its own. 26
+ places in the docblocks; 22 marked and 1 unmarked in `expected-new.tex`,
+ whose marks in `[expected.expected]` go from 9 / 2 to 20 / 13 and in
+ `[expected.void]` from 7 / 0 to 18 / 11. Tests added for the guarantee;
+ 1258 pass. 105 notes, unchanged. Left: the same-type move constructor
+ and assignment still read `std::move(rhs.error())`, under the rebinding
+ paragraph; and D4280's prose does not yet say why its wording marks
+ these 22 places.
+- 2026-11-30: D4280 now says why.
+ Its section on shallow conversions gained a closing paragraph naming the draft's `std::move(error())` as access-then-move and `std::move(unex).error()` as the replacement.
+ The section is retitled "An rvalue `expected` must not let its referent be stolen", since it now covers the rvalue observers and monadic operations as well as conversions.
+ Left: the same-type move constructor and assignment, as above.
+- 2026-11-30: a 23rd place marked in `expected-new.tex`, the *Mandates* of `value() &&` in `[expected.object.obs]`.
+ A `\linebreak{}` inside `std::move` had hidden it from the search.
+ The rebinding paragraph covers the move assignment only, not the two move constructors, which are in `[expected.object.cons]` and `[expected.void.cons]` with no such paragraph.
+ For a reference `E` their `std::move(rhs.error())` initializes an `unexpected` from an rvalue, which `[expected.un.ref]` rejects.
+
+### reference-result-of-transform
+
+**Question.** `transform` and `transform_error` compute the result type with `remove_cv_t`, which leaves a reference a reference.
+When the callable returns an lvalue reference, is the call ill-formed, or does it yield an `expected` that refers to the result?
+**Status.** DECIDED
+**Decision.** It yields a reference `expected`: `transform` returns `expected` and `transform_error` returns `expected`, on all three class templates.
+An rvalue reference result stays ill-formed.
+**Why.** `optional` is the precedent.
+P2988R12 widened "valid contained type" to admit lvalue references, and `optional::transform` *Mandates* that definition, so a callable returning `U&` yields `optional`.
+Before this the two operations disagreed with each other and with the wording.
+The paper kept the draft's definition of "valid value type", which excludes references, so its `transform` rejected a reference result and, read literally, so did `expected` itself, while the code returned `expected`.
+The paper's relaxed rule for `unexpected` already admitted a reference `G` in `transform_error`, while the code rejected it and four compile-fail tests held it there.
+**Decided by.** Steve Downey, 2026-11-30: "4 and 5 are decided by the Optional precedent, at least in spirit."
+
+**Log.**
+- 2026-11-30: opened and decided, from a check of the base specializations against the small changes P2988R12 and its follow-up issues made to `optional` outside `[optional.ref]`.
+ Carried out on `specgen-0.58`.
+ The definition of "valid value type" in `[expected.object.general]` gains lvalue references to non-array object types, and the four *Returns* of `transform` say what `val` is for a reference `U`.
+ The code's `transform_error` assertions admit an lvalue reference `G`.
+ The four compile-fail tests now return an rvalue reference, which is still rejected, and are renamed `*_rvalue_ref_result_fail`.
+ Left: the `transform` docblocks say `expected(in_place, ...)`, which the reference specialization deletes; the code and the paper do not.
+ Left: the hazard `optional` also has, a callable that returns a reference into the value or error of an rvalue `expected`, is not diagnosed.
+- 2026-11-30: the same check found, and this branch fixes, in the paper's wording: the move constructors' `std::move(rhs.error())`, now `std::move(rhs.unex)` (see [rvalue-error-binding](#rvalue-error-binding)); the *Constraints* of `swap`, which tested `is_swappable_v` on a reference; and the *Mandates* of `value()`, which tested `is_copy_constructible_v` on a reference and were missing from `[expected.ref.obs]`.
+ In the code: the deleted constructor templates of `expected` and `unexpected` deduced the class itself from a const rvalue and made its copy a hard error under gcc-16.
+ Left for a ruling: the *Remarks* that delete those constructors have the same hole in the paper; `[expected.syn]` declares neither `expected` nor `unexpected`; and `expected` has no assertion that a reference `E` refers to an object type.
+
+- 2026-11-30: the items left above are done, at Steve Downey's direction.
+ The *Remarks* that delete the reference constructors now read "This constructor is defined as deleted if ...", after *Constraints* that no longer mention the temporary, as `optional`'s do; this covers the `in_place_t` constructor of `unexpected` too, which the code deletes and the paper had only constrained.
+ `[expected.syn]` declares `unexpected` and `expected`.
+ The six `transform` docblocks have the draft's shape, with *Mandates*, and no longer name the `in_place_t` constructor.
+ `expected` and `expected` assert that `E`, less any reference, is an object type, as `expected` and `unexpected` already did; nothing that compiled before is rejected, since `unexpected` already refused a function type, and the paper's `[expected.un.ref]` now says so.
+ D4280's "Monadic operations are uniform" states the reference result and the dangling hazard, which is left to the caller as it is for `optional`.
+ Left: `[expected.ref.general]` does not mark `value()` freestanding-deleted, though the synopsis now calls the specialization partially freestanding.
+- 2026-11-30: `value()` is marked freestanding-deleted in `[expected.ref.general]` and in the two docblocks, which closes the item above.
+ D4280 gains a short section, "A referent is a non-array object type": `optional` admits array and function referents and LWG4304 keeps that working, and the paper says it does not rewrite `expected` to follow without explicit direction.
+
### specgen-pin
**Question.** How is the specgen version fixed and recorded?
@@ -1181,6 +1373,25 @@ the availability test in the makefile, and the pin are revisited then.
status changed: a specgen from 0.44.0 on fails `make wording` on the
headers on `main`, where an older one succeeds. The cost of having no pin
is now a build that works or not by which specgen is on `PATH`.
+- 2026-11-30: 0.58.0 (`0d034bc`) installed from the release archive. The
+ checked-in wording on `upstream/main` (`54bd02e`) no longer matched any
+ current specgen's render, so `make wording-check` failed there; nothing
+ runs it in CI. Regenerated (branch `specgen-0.58`). `--validate` gives
+ the same 107 notes as 0.56.2. What moved: code wraps at the draft's 97
+ columns (specgen#446), and a synopsis puts a short template head on its
+ declaration's line, as the draft sometimes does; the macro, deduction
+ guide and section-prose fixes above; and 21 derived "Let" paragraphs
+ (specgen#442), the subject of [derived-let](#derived-let). Two defects
+ found, each with a scratch reproduction, not yet filed: a qualified
+ exposition-only name, `typename expected::error_value_type`, in a
+ derived *Constraints* is shown as source, worked around with an authored
+ `\constraints` on the primary's two `error_or`; and code is wrapped by its
+ width before a specifier macro is removed, so
+ `operator=(const bad_expected_access&) noexcept;` breaks at 80 columns
+ rendered.
+- 2026-11-30: both filed, as
+ [specgen#487](https://github.com/steve-downey/specgen/issues/487) and
+ [specgen#488](https://github.com/steve-downey/specgen/issues/488).
## Requests to specgen
@@ -1228,6 +1439,14 @@ Filed 2026-11-19, from [synopsis-shape](#synopsis-shape):
| [specgen#386](https://github.com/steve-downey/specgen/issues/386) | An empty `\constraints` removes the derived element, which the guide does not say; and a *Remarks* cannot cover a derived conjunct. | [overload-partitions](#overload-partitions), [validation-findings](#validation-findings) |
| [specgen#392](https://github.com/steve-downey/specgen/issues/392) | With `--baseline-draft`, a `// \ref{...}` comment in a `\verbatim-synopsis` block is marked removed and added again where the draft has the same bytes. | [front-matter](#front-matter), [generated-diff](#generated-diff) |
+Filed 2026-11-30, from the 0.58.0 round, each with a scratch-header
+reproduction:
+
+| Issue | What | For |
+|---|---|---|
+| [specgen#487](https://github.com/steve-downey/specgen/issues/487) | A derived *Constraints* shows a qualified exposition-only name, `typename box::value_kind`, as source, and the drift check does not match it with the unqualified authored spelling. | the primary template's `error_or` |
+| [specgen#488](https://github.com/steve-downey/specgen/issues/488) | Code is wrapped by its width before a specifier macro is removed, so it breaks, and aligns its continuation, by the macro's width. | `[expected.bad.void]` |
+
Not filed: a set of Doxygen `ALIASES` for specgen's markers, until
[api-site-markup](#api-site-markup) has one that works here.
diff --git a/include/beman/expected/bad_expected_access.hpp b/include/beman/expected/bad_expected_access.hpp
index 716416da..6770b4e4 100644
--- a/include/beman/expected/bad_expected_access.hpp
+++ b/include/beman/expected/bad_expected_access.hpp
@@ -35,25 +35,6 @@ namespace std {
}
*/
-/***
-22.8.5 Class template specialization bad_expected_access[expected.bad.void]
-namespace std {
- template<>
- class bad_expected_access : public exception {
- protected:
- constexpr bad_expected_access() noexcept;
- constexpr bad_expected_access(const bad_expected_access&) noexcept;
- constexpr bad_expected_access(bad_expected_access&&) noexcept;
- constexpr bad_expected_access& operator=(const bad_expected_access&) noexcept;
- constexpr bad_expected_access& operator=(bad_expected_access&&) noexcept;
- constexpr ~bad_expected_access();
-
- public:
- constexpr const char* what() const noexcept override;
- };
-}
- */
-
namespace beman {
namespace expected {
@@ -64,12 +45,18 @@ class bad_expected_access;
template <>
class bad_expected_access : public std::exception {
protected:
- BEMAN_EXPECTED_CONSTEXPR_EXCEPTION bad_expected_access() noexcept = default;
- BEMAN_EXPECTED_CONSTEXPR_EXCEPTION bad_expected_access(const bad_expected_access&) noexcept = default;
- BEMAN_EXPECTED_CONSTEXPR_EXCEPTION bad_expected_access(bad_expected_access&&) noexcept = default;
+ //! \omit default
+ BEMAN_EXPECTED_CONSTEXPR_EXCEPTION bad_expected_access() noexcept = default;
+ //! \omit default
+ BEMAN_EXPECTED_CONSTEXPR_EXCEPTION bad_expected_access(const bad_expected_access&) noexcept = default;
+ //! \omit default
+ BEMAN_EXPECTED_CONSTEXPR_EXCEPTION bad_expected_access(bad_expected_access&&) noexcept = default;
+ //! \omit default
BEMAN_EXPECTED_CONSTEXPR_EXCEPTION bad_expected_access& operator=(const bad_expected_access&) noexcept = default;
- BEMAN_EXPECTED_CONSTEXPR_EXCEPTION bad_expected_access& operator=(bad_expected_access&&) noexcept = default;
- BEMAN_EXPECTED_CONSTEXPR_EXCEPTION ~bad_expected_access() = default;
+ //! \omit default
+ BEMAN_EXPECTED_CONSTEXPR_EXCEPTION bad_expected_access& operator=(bad_expected_access&&) noexcept = default;
+ //! \omit default
+ BEMAN_EXPECTED_CONSTEXPR_EXCEPTION ~bad_expected_access() = default;
public:
BEMAN_EXPECTED_CONSTEXPR_EXCEPTION const char* what() const noexcept override;
diff --git a/include/beman/expected/expected.hpp b/include/beman/expected/expected.hpp
index d23cac73..94cb04c9 100644
--- a/include/beman/expected/expected.hpp
+++ b/include/beman/expected/expected.hpp
@@ -38,6 +38,9 @@
//! // \ref{expected.unexpected}, class template \tcode{unexpected}
//! template class unexpected;
//!
+//! // \ref{expected.un.ref}, partial specialization of \tcode{unexpected} for lvalue reference types
+//! template class unexpected;
+//!
//! // \ref{expected.bad}, class template \tcode{bad_expected_access}
//! template class bad_expected_access;
//!
@@ -55,6 +58,9 @@
//!
//! // \ref{expected.void}, partial specialization of \tcode{expected} for \tcode{void} types
//! template requires is_void_v class expected; // partially freestanding
+//!
+//! // \ref{expected.ref}, partial specialization of \tcode{expected} for lvalue reference types
+//! template class expected; // partially freestanding
//! }
/// END [expected.syn]
@@ -142,12 +148,14 @@ constexpr bool converts_from_any_cvref = std::disjunction_v` is `void` or a complete non-array object type that is not
-//! `in_place_t`, `unexpect_t`, or a specialization of `unexpected`. A program
-//! which instantiates class template `expected` with an argument `T`
-//! that is not a valid value type for `expected` is ill-formed. A program that
-//! instantiates the definition of the template `expected` with a type
-//! for the `E` parameter that is not a valid template argument for
-//! `unexpected` is ill-formed.
+//! `in_place_t`, `unexpect_t`, or a specialization of `unexpected`, or if `T`
+//! is an lvalue reference to an object type that is not an array
+//! type\iref{expected.ref.general}. A program which instantiates class
+//! template `expected` with an argument `T` that is not a valid value
+//! type for `expected` is ill-formed. A program that instantiates the
+//! definition of the template `expected` with a type for the `E`
+//! parameter that is not a valid template argument for `unexpected` is
+//! ill-formed.
//! \covers mandates !is_reference_v
//! \covers mandates !is_rvalue_reference_v
//! \covers mandates !is_void_v>
@@ -156,6 +164,7 @@ constexpr bool converts_from_any_cvref = std::disjunction_v
//! \covers mandates !is-unexpected-specialization>::value
//! \covers mandates !is_array_v>
+//! \covers mandates is_object_v>
//!
//! When `T` is not \cv{} `void`, it shall meet the \oldconcept{Destructible}
//! requirements (\tref{cpp17.destructible}). If `E` is not an lvalue reference
@@ -171,6 +180,7 @@ class expected {
static_assert(!detail::is_unexpected_specialization>::value,
"T must not be a specialization of unexpected");
static_assert(!std::is_array_v>, "E must not be an array type");
+ static_assert(std::is_object_v>, "E must be an object type");
private:
//! \expos
@@ -255,7 +265,7 @@ class expected {
template >
requires(!std::is_same_v, std::in_place_t> &&
!std::is_same_v, unexpect_t> &&
- !std::is_same_v, expected> && std::is_constructible_v &&
+ !std::is_same_v, expected> && std::is_constructible_v &&
!detail::is_unexpected_specialization>::value &&
(!std::is_same_v> ||
!detail::is_expected_specialization>::value))
@@ -429,7 +439,7 @@ class expected {
// Assignment from value U&&
template >
- requires(!std::is_same_v> &&
+ requires(!std::is_same_v, std::remove_cvref_t> &&
!detail::is_unexpected_specialization>::value &&
std::is_constructible_v && std::is_assignable_v &&
(std::is_nothrow_constructible_v || std::is_nothrow_move_constructible_v ||
@@ -536,11 +546,13 @@ class expected {
constexpr T value_or(U&& def) &&;
template
- requires(std::is_copy_constructible_v && std::is_convertible_v)
+ requires(std::is_copy_constructible_v>> &&
+ std::is_convertible_v>>)
constexpr error_value_type error_or(G&& def) const&;
template
- requires(std::is_move_constructible_v && std::is_convertible_v)
+ requires(std::is_move_constructible_v>> &&
+ std::is_convertible_v>>)
constexpr error_value_type error_or(G&& def) &&;
// \ref{expected.object.monadic}, monadic operations
@@ -647,6 +659,7 @@ class expected {
// \rSec3[expected.object.cons]{Constructors}
+//! \omit noexcept
//! \effects Value-initializes `val`.
//! \ensures `has_value()` is `true`.
//! \throws Any exception thrown by the initialization of `val`.
@@ -657,6 +670,7 @@ constexpr expected::expected() noexcept(std::is_nothrow_default_constructi
std::construct_at(std::addressof(val_));
}
+//! \omit noexcept
//! \constraints
//! \effects If `rhs.has_value()` is `true`, direct-non-list-initializes
//! `val` with `*rhs`. Otherwise, direct-non-list-initializes `unex` with
@@ -687,7 +701,7 @@ constexpr expected::expected(const expected& rhs) noexcept(std::is_nothrow
//! `true`.
//! \effects If `rhs.has_value()` is `true`, direct-non-list-initializes
//! `val` with `std::move(*rhs)`. Otherwise, direct-non-list-initializes
-//! `unex` with `std::move(rhs.error())`.
+//! `unex` with `std::move(rhs.unex)`.
//! \ensures `rhs.has_value()` is unchanged; `rhs.has_value() ==
//! this->has_value()` is `true`.
//! \throws Any exception thrown by the initialization of `val` or `unex`.
@@ -931,6 +945,7 @@ constexpr expected::~expected()
// =============================================================================
// \rSec3[expected.object.assign]{Assignment}
+//! \omit noexcept
//! \constraints
//! \effects If `this->has_value() && rhs.has_value()`, equivalent to `val
//! = *rhs`. Otherwise, if `this->has_value()`, equivalent to
@@ -993,7 +1008,7 @@ constexpr expected& expected::operator=(const expected& rhs) noexcep
//! is_nothrow_move_constructible_v` is `true`.
//! \effects If `this->has_value() && rhs.has_value()`, equivalent to `val
//! = std::move(*rhs)`. Otherwise, if `this->has_value()`, equivalent to
-//! `reinit-expected(unex, val, std::move(rhs.error()))`. Otherwise, if
+//! `reinit-expected(unex, val, std::move(rhs.unex))`. Otherwise, if
//! `rhs.has_value()`, equivalent to `reinit-expected(val, unex,
//! std::move(*rhs))`. Otherwise, equivalent to `unex =
//! std::move(rhs.unex)`. Then, if no exception was thrown, equivalent to:
@@ -1346,7 +1361,7 @@ constexpr bool expected::has_value() const noexcept {
//! \freestanding-deleted
//! \group obs-value-lval
-//! \mandates `is_copy_constructible_v` is `true`.
+//! \mandates `is_copy_constructible_v` is `true`.
//! \returns `val`, if `has_value()` is `true`.
//! \throws `bad_expected_access(as_const(error()))` if `has_value()` is
//! `false`.
@@ -1370,10 +1385,11 @@ constexpr T& expected::value() & {
//! \freestanding-deleted
//! \group obs-value-rval
-//! \mandates `is_copy_constructible_v` is `true` and
-//! `is_constructible_v` is `true`.
+//! \mandates `is_copy_constructible_v` is `true` and
+//! `is_constructible_v` is `true`.
//! \returns `std::move(val)`, if `has_value()` is `true`.
-//! \throws `bad_expected_access(std::move(error()))` if `has_value()` is
+//! \throws `bad_expected_access(std::move(unex).error())` if `has_value()` is
//! `false`.
template
constexpr const T&& expected::value() const&& {
@@ -1381,7 +1397,8 @@ constexpr const T&& expected::value() const&& {
static_assert(std::is_copy_constructible_v && std::is_move_constructible_v,
"value() const&& requires E to be copy and move constructible");
} else {
- static_assert(std::is_copy_constructible_v && std::is_constructible_v,
+ static_assert(std::is_copy_constructible_v &&
+ std::is_constructible_v,
"value() && requires E be copy-constructible and constructible from move(error())");
}
if (!has_val_)
@@ -1397,7 +1414,8 @@ constexpr T&& expected::value() && {
static_assert(std::is_copy_constructible_v && std::is_move_constructible_v,
"value() && requires E to be copy and move constructible");
} else {
- static_assert(std::is_copy_constructible_v && std::is_constructible_v,
+ static_assert(std::is_copy_constructible_v &&
+ std::is_constructible_v,
"value() && requires E be copy-constructible and constructible from move(error())");
}
if (!has_val_)
@@ -1472,28 +1490,32 @@ constexpr T expected::value_or(U&& def) && {
return static_cast(std::forward(def));
}
+//! \constraints `is_copy_constructible_v` is `true` and
+//! `is_convertible_v` is `true`.
//! \mandates `is_copy_constructible_v` is `true` and
//! `is_convertible_v` is `true`.
//! \returns `std::forward(def)` if `has_value()` is `true`, `error()`
//! otherwise.
template
template
- requires(std::is_copy_constructible_v::error_value_type> &&
- std::is_convertible_v::error_value_type>)
+ requires(std::is_copy_constructible_v>> &&
+ std::is_convertible_v>>)
constexpr typename expected::error_value_type expected::error_or(G&& def) const& {
if (!has_val_)
return unex_.error();
return static_cast(std::forward(def));
}
+//! \constraints `is_move_constructible_v` is `true` and
+//! `is_convertible_v` is `true`.
//! \mandates `is_move_constructible_v` is `true` and
//! `is_convertible_v` is `true`.
//! \returns `std::forward(def)` if `has_value()` is `true`,
-//! `std::move(error())` otherwise.
+//! `std::move(unex).error()` otherwise.
template
template
- requires(std::is_move_constructible_v::error_value_type> &&
- std::is_convertible_v::error_value_type>)
+ requires(std::is_move_constructible_v>> &&
+ std::is_convertible_v>>)
constexpr typename expected::error_value_type expected::error_or(G&& def) && {
if (!has_val_)
return std::move(unex_).error();
@@ -1505,17 +1527,15 @@ constexpr typename expected::error_value_type expected::error_or(G&&
//! \group monadic-and-then-lval
//! \constraints `is_constructible_v` is `true`.
-//! \mandates `remove_cvref_t>` is a
-//! specialization of `expected` and its `error_type` is the same type as
-//! `E`.
+//! \mandates `U` is a specialization of `expected` and
+//! `is_same_v` is `true`.
//! \effects Equivalent to: `if (has_value()) return
//! invoke(std::forward(f), val); else return U(unexpect, error());`
-//! where `U` is `remove_cvref_t>`.
template
template
requires std::is_constructible_v
constexpr auto expected::and_then(F&& f) & {
- using U = std::remove_cvref_t>;
+ using U = std::remove_cvref_t>;
static_assert(detail::is_expected_specialization::value,
"and_then: F must return a specialization of expected");
static_assert(std::is_same_v,
@@ -1526,20 +1546,18 @@ constexpr auto expected::and_then(F&& f) & {
}
//! \group monadic-and-then-rval
-//! \constraints `is_constructible_v` is
+//! \constraints `is_constructible_v` is
//! `true`.
-//! \mandates `remove_cvref_t>`
-//! is a specialization of `expected` and its `error_type` is the same
-//! type as `E`.
+//! \mandates `U` is a specialization of `expected` and
+//! `is_same_v` is `true`.
//! \effects Equivalent to: `if (has_value()) return
//! invoke(std::forward(f), std::move(val)); else return U(unexpect,
-//! std::move(error()));` where `U` is `remove_cvref_t>`.
+//! std::move(unex).error());`
template
template
requires std::is_constructible_v
constexpr auto expected::and_then(F&& f) && {
- using U = std::remove_cvref_t>;
+ using U = std::remove_cvref_t>;
static_assert(detail::is_expected_specialization::value,
"and_then: F must return a specialization of expected");
static_assert(std::is_same_v,
@@ -1554,7 +1572,7 @@ template
template
requires std::is_constructible_v
constexpr auto expected::and_then(F&& f) const& {
- using U = std::remove_cvref_t>;
+ using U = std::remove_cvref_t>;
static_assert(detail::is_expected_specialization::value,
"and_then: F must return a specialization of expected");
static_assert(std::is_same_v,
@@ -1569,7 +1587,7 @@ template
template
requires std::is_constructible_v
constexpr auto expected::and_then(F&& f) const&& {
- using U = std::remove_cvref_t>;
+ using U = std::remove_cvref_t>;
static_assert(detail::is_expected_specialization::value,
"and_then: F must return a specialization of expected");
static_assert(std::is_same_v,
@@ -1581,16 +1599,14 @@ constexpr auto expected::and_then(F&& f) const&& {
//! \group monadic-or-else-lval
//! \constraints `is_constructible_v` is `true`.
-//! \mandates `remove_cvref_t>` is
-//! `expected` for some type `X`.
+//! \mandates `G` is `expected` for some type `X`.
//! \effects Equivalent to: `if (has_value()) return G(in_place, val); else
-//! return invoke(std::forward(f), error());` where `G` is
-//! `remove_cvref_t>`.
+//! return invoke(std::forward(f), error());`
template
template
requires std::is_constructible_v
constexpr auto expected::or_else(F&& f) & {
- using G = std::remove_cvref_t>;
+ using G = std::remove_cvref_t>;
static_assert(detail::is_expected_specialization::value, "or_else: F must return a specialization of expected");
static_assert(std::is_same_v>,
"or_else: F must return expected for some X");
@@ -1602,17 +1618,15 @@ constexpr auto expected::or_else(F&& f) & {
//! \group monadic-or-else-rval
//! \constraints `is_constructible_v` is
//! `true`.
-//! \mandates `remove_cvref_t>` is `expected` for some type `X`.
+//! \mandates `G` is `expected` for some type `X`.
//! \effects Equivalent to: `if (has_value()) return G(in_place,
//! std::move(val)); else return invoke(std::forward(f),
-//! std::move(error()));` where `G` is `remove_cvref_t>`.
+//! std::move(unex).error());`
template
template
requires std::is_constructible_v
constexpr auto expected::or_else(F&& f) && {
- using G = std::remove_cvref_t>;
+ using G = std::remove_cvref_t>;
static_assert(detail::is_expected_specialization::value, "or_else: F must return a specialization of expected");
static_assert(std::is_same_v>,
"or_else: F must return expected for some X");
@@ -1626,7 +1640,7 @@ template
template
requires std::is_constructible_v
constexpr auto expected::or_else(F&& f) const& {
- using G = std::remove_cvref_t>;
+ using G = std::remove_cvref_t>;
static_assert(detail::is_expected_specialization::value, "or_else: F must return a specialization of expected");
static_assert(std::is_same_v>,
"or_else: F must return expected for some X");
@@ -1640,7 +1654,7 @@ template
template
requires std::is_constructible_v
constexpr auto expected::or_else(F&& f) const&& {
- using G = std::remove_cvref_t>;
+ using G = std::remove_cvref_t>;
static_assert(detail::is_expected_specialization::value, "or_else: F must return a specialization of expected");
static_assert(std::is_same_v>,
"or_else: F must return expected