From 585b59ff71d4a53c796ed8f956e91060f479a3f0 Mon Sep 17 00:00:00 2001 From: Steve Downey Date: Mon, 30 Nov 2026 00:11:33 -0500 Subject: [PATCH 01/24] Regenerate the wording with specgen 0.58.0 The checked-in wording was generated by an older specgen, of the 0.47 line as far as the plan records, and `make wording-check` no longer passed against it with any current specgen. Regenerated with 0.58.0 (0d034bc); `--validate` reports the same 107 notes as 0.56.2 and nothing above a note. What moved, by the specgen change that moved it: - Code in item declarations and synopses wraps at the draft's 97 columns (specgen#446). Template heads short enough to share a line with their declaration in a synopsis now do, as the draft writes `template constexpr E error_or(G&&) const &;`. - BEMAN_EXPECTED_CONSTEXPR_EXCEPTION no longer appears in the bad_expected_access synopses (specgen#349). - The deduction guide for unexpected is in its class synopsis. - A body-local alias named by the assertions that give a derived Mandates is introduced by a derived "Let U be ..." paragraph (specgen#442), 21 of them, all in the monadic operations and in [expected.ref]. - Definitions with nothing to contribute no longer leave a stray blank line (specgen#436). One regression comes with it: the derived Constraints of the primary template's two error_or overloads now read `typename expected::error_value_type` where they read `\exposid{error-value-type}`. The next commit works around it. Against the working draft at n5054, `make wording-gap` counts slightly fewer change marks than 0.56.2 does on the same headers. --- papers/wording/expected.tex | 201 ++++++++++-------- papers/wording/fragments/expected.bad.tex | 4 +- .../wording/fragments/expected.bad.void.tex | 18 +- .../wording/fragments/expected.expected.tex | 57 ++--- papers/wording/fragments/expected.ref.tex | 60 +++--- .../wording/fragments/expected.unexpected.tex | 20 +- papers/wording/fragments/expected.void.tex | 42 ++-- 7 files changed, 220 insertions(+), 182 deletions(-) diff --git a/papers/wording/expected.tex b/papers/wording/expected.tex index b245cec5..60911673 100644 --- a/papers/wording/expected.tex +++ b/papers/wording/expected.tex @@ -73,10 +73,8 @@ is_nothrow_constructible_v); template - constexpr explicit unexpected( - in_place_t, initializer_list il, - Args&&... args) noexcept(is_nothrow_constructible_v&, - Args...>); + constexpr explicit unexpected(in_place_t, initializer_list il, Args&&... args) noexcept( + is_nothrow_constructible_v&, Args...>); constexpr unexpected& operator=(const unexpected&) = default; constexpr unexpected& operator=(unexpected&&) = default; @@ -91,19 +89,19 @@ template friend constexpr bool operator==(const unexpected& x, const unexpected& y); - friend constexpr void swap(unexpected& x, - unexpected& y) noexcept(noexcept(x.swap(y))); + friend constexpr void swap(unexpected& x, unexpected& y) noexcept(noexcept(x.swap(y))); private: E @\exposid{unex}@; // \expos }; + + template unexpected(E) -> unexpected; } \end{codeblock} \pnum A program that instantiates the definition of \tcode{unexpected} for a non-object type other than an lvalue reference type, an array type, a specialization of \tcode{unexpected}, or a cv-qualified type is ill-formed. - \rSec3[expected.un.cons]{Constructors} \indexlibraryctor{unexpected}% @@ -133,7 +131,8 @@ \indexlibraryctor{unexpected}% \begin{itemdecl} template - constexpr explicit unexpected(in_place_t, Args&&... args) noexcept(is_nothrow_constructible_v); + constexpr explicit unexpected(in_place_t, + Args&&... args) noexcept(is_nothrow_constructible_v); \end{itemdecl} \begin{itemdescr} @@ -153,8 +152,8 @@ \indexlibraryctor{unexpected}% \begin{itemdecl} template - constexpr explicit unexpected(in_place_t, initializer_list il, - Args&&... args) noexcept(is_nothrow_constructible_v&, Args...>); + constexpr explicit unexpected(in_place_t, initializer_list il, Args&&... args) noexcept( + is_nothrow_constructible_v&, Args...>); \end{itemdecl} \begin{itemdescr} @@ -285,7 +284,6 @@ \pnum A program that instantiates the definition of \tcode{unexpected} for a referenced type that is not an object type, an array type, or a specialization of \tcode{unexpected} is ill-formed. Unlike the primary template, \tcode{E} may be a cv-qualified type. - \indexlibraryctor{unexpected}% \begin{itemdecl} template @@ -387,8 +385,8 @@ template class @\libglobal{bad_expected_access}@ : public bad_expected_access { public: - BEMAN_EXPECTED_CONSTEXPR_EXCEPTION explicit bad_expected_access(E e); - BEMAN_EXPECTED_CONSTEXPR_EXCEPTION const char* what() const noexcept override; + explicit bad_expected_access(E e); + const char* what() const noexcept override; constexpr E& error() & noexcept; constexpr const E& error() const& noexcept; constexpr E&& error() && noexcept; @@ -456,19 +454,19 @@ template<> class @\libglobal{bad_expected_access}@ : public 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; - BEMAN_EXPECTED_CONSTEXPR_EXCEPTION bad_expected_access& operator=( + bad_expected_access() noexcept = default; + bad_expected_access(const bad_expected_access&) noexcept = + default; + bad_expected_access(bad_expected_access&&) noexcept = + default; + bad_expected_access& operator=( const bad_expected_access&) noexcept = default; - BEMAN_EXPECTED_CONSTEXPR_EXCEPTION bad_expected_access& operator=( + bad_expected_access& operator=( bad_expected_access&&) noexcept = default; - BEMAN_EXPECTED_CONSTEXPR_EXCEPTION ~bad_expected_access() = default; + ~bad_expected_access() = default; public: - BEMAN_EXPECTED_CONSTEXPR_EXCEPTION const char* what() const noexcept override; + const char* what() const noexcept override; }; } \end{codeblock} @@ -506,22 +504,18 @@ constexpr expected() noexcept(is_nothrow_default_constructible_v); - constexpr expected(const expected& rhs) noexcept( - is_nothrow_copy_constructible_v && is_nothrow_copy_constructible_v); + constexpr expected(const expected& rhs) noexcept(is_nothrow_copy_constructible_v && + is_nothrow_copy_constructible_v); constexpr expected(expected&& rhs) noexcept(@\seebelow@); - template - constexpr explicit(@\seebelow@) expected(const expected& rhs); + template constexpr explicit(@\seebelow@) expected(const expected& rhs); - template - constexpr explicit(@\seebelow@) expected(expected&& rhs); + template constexpr explicit(@\seebelow@) expected(expected&& rhs); - template - constexpr explicit(@\seebelow@) expected(const expected& rhs); + template constexpr explicit(@\seebelow@) expected(const expected& rhs); - template - constexpr explicit(@\seebelow@) expected(expected&& rhs); + template constexpr explicit(@\seebelow@) expected(expected&& rhs); template> constexpr explicit(!is_convertible_v) expected(U&& v); @@ -529,12 +523,10 @@ template constexpr explicit(!is_convertible_v) expected(const unexpected& e); - template - constexpr explicit(!is_convertible_v) expected(unexpected&& e); + template constexpr explicit(!is_convertible_v) expected(unexpected&& e); template - constexpr explicit(!is_convertible_v) - expected(const unexpected& e) noexcept; + constexpr explicit(!is_convertible_v) expected(const unexpected& e) noexcept; template constexpr explicit(!is_convertible_v) expected(unexpected&& e) noexcept; @@ -631,11 +623,9 @@ template> constexpr T value_or(U&& def) &&; - template - constexpr @\exposid{error-value-type}@ error_or(G&& def) const&; + template constexpr @\exposid{error-value-type}@ error_or(G&& def) const&; - template - constexpr @\exposid{error-value-type}@ error_or(G&& def) &&; + template constexpr @\exposid{error-value-type}@ error_or(G&& def) &&; // \ref{expected.object.monadic}, monadic operations @@ -665,8 +655,7 @@ requires(!is_void_v) friend constexpr bool operator==(const expected& x, const expected& y); - template - friend constexpr bool operator==(const expected& x, const T2& val); + template friend constexpr bool operator==(const expected& x, const T2& val); template friend constexpr bool operator==(const expected& x, const unexpected& e); @@ -693,7 +682,6 @@ \pnum When \tcode{T} is not \cv{} \tcode{void}, it shall meet the \oldconcept{Destructible} requirements (\tref{cpp17.destructible}). If \tcode{E} is not an lvalue reference type, \tcode{E} shall meet the \oldconcept{Destructible} requirements. - \rSec3[expected.object.cons]{Constructors} \indexlibraryctor{expected}% @@ -726,7 +714,6 @@ \end{itemdecl} \begin{itemdescr} - \pnum \effects If \tcode{rhs.has_value()} is \tcode{true}, direct-non-list-initializes \exposid{val} with \tcode{*rhs}. Otherwise, direct-non-list-initializes \exposid{unex} with \tcode{rhs.error()}. @@ -1062,7 +1049,6 @@ \end{itemdecl} \begin{itemdescr} - \pnum \effects If \tcode{has_value()} is \tcode{true}, destroys \exposid{val}, otherwise destroys \exposid{unex}. @@ -1083,7 +1069,6 @@ \end{itemdecl} \begin{itemdescr} - \pnum \effects If \tcode{this->has_value() \&\& rhs.has_value()}, equivalent to \tcode{\exposid{val} = *rhs}. Otherwise, if \tcode{this->has_value()}, equivalent to \tcode{reinit-expected(\exposid{unex}, \exposid{val}, rhs.error())}. Otherwise, if \tcode{rhs.has_value()}, equivalent to \tcode{reinit-expected(\exposid{val}, \exposid{unex}, *rhs)}. Otherwise, equivalent to \tcode{\exposid{unex} = rhs.\exposid{unex}}. Then, if no exception was thrown, equivalent to: \tcode{\exposid{has_val} = rhs.has_value(); return *this;} When \tcode{E} is an lvalue reference type, each of the cases above that initializes or assigns \exposid{unex} rebinds it: \exposid{unex} comes to refer to the same object as \tcode{rhs}'s error. No previously or subsequently referenced object is assigned through. @@ -1474,7 +1459,7 @@ \begin{itemdescr} \pnum \constraints -\tcode{is_copy_constructible_v::\exposid{error-value-type}>} is \tcode{true} and \tcode{is_convertible_v::\exposid{error-value-type}>} is \tcode{true}. +\tcode{is_copy_constructible_v::error_value_type>} is \tcode{true} and \tcode{is_convertible_v::error_value_type>} is \tcode{true}. \pnum \mandates @@ -1494,7 +1479,7 @@ \begin{itemdescr} \pnum \constraints -\tcode{is_move_constructible_v::\exposid{error-value-type}>} is \tcode{true} and \tcode{is_convertible_v::\exposid{error-value-type}>} is \tcode{true}. +\tcode{is_move_constructible_v::error_value_type>} is \tcode{true} and \tcode{is_convertible_v::error_value_type>} is \tcode{true}. \pnum \mandates @@ -1516,6 +1501,9 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{U} be \tcode{remove_cvref_t>}. + \pnum \constraints \tcode{is_constructible_v} is \tcode{true}. @@ -1538,6 +1526,9 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{U} be \tcode{remove_cvref_t>}. + \pnum \constraints \tcode{is_constructible_v} is \tcode{true}. @@ -1560,6 +1551,9 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{G} be \tcode{remove_cvref_t>}. + \pnum \constraints \tcode{is_constructible_v} is \tcode{true}. @@ -1582,6 +1576,9 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{G} be \tcode{remove_cvref_t>}. + \pnum \constraints \tcode{is_constructible_v} is \tcode{true}. @@ -1640,6 +1637,9 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{G} be \tcode{remove_cv_t>}. + \pnum \constraints \tcode{is_constructible_v} is \tcode{true}. @@ -1667,6 +1667,9 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{G} be \tcode{remove_cv_t>}. + \pnum \constraints \tcode{is_constructible_v} is \tcode{true}. @@ -1762,14 +1765,12 @@ constexpr expected() noexcept; - constexpr expected(const expected& rhs) noexcept( - is_nothrow_copy_constructible_v); + constexpr expected(const expected& rhs) noexcept(is_nothrow_copy_constructible_v); constexpr expected(expected&& rhs) noexcept(is_nothrow_move_constructible_v); template - constexpr explicit(!is_convertible_v) - expected(const expected& rhs); + constexpr explicit(!is_convertible_v) expected(const expected& rhs); template constexpr explicit(!is_convertible_v) expected(expected&& rhs); @@ -1777,12 +1778,10 @@ template constexpr explicit(!is_convertible_v) expected(const unexpected& e); - template - constexpr explicit(!is_convertible_v) expected(unexpected&& e); + template constexpr explicit(!is_convertible_v) expected(unexpected&& e); template - constexpr explicit(!is_convertible_v) - expected(const unexpected& e) noexcept; + constexpr explicit(!is_convertible_v) expected(const unexpected& e) noexcept; template constexpr explicit(!is_convertible_v) expected(unexpected&& e) noexcept; @@ -1811,8 +1810,7 @@ constexpr expected(unexpect_t, initializer_list, Args&&...) = delete; template - constexpr explicit(!is_convertible_v) - expected(const expected& rhs); + constexpr explicit(!is_convertible_v) expected(const expected& rhs); template constexpr explicit(!is_convertible_v) expected(expected&& rhs); @@ -1865,11 +1863,9 @@ constexpr const E&& error() const&& noexcept; constexpr E&& error() && noexcept; - template - constexpr @\exposid{error-value-type}@ error_or(G&& def) const&; + template constexpr @\exposid{error-value-type}@ error_or(G&& def) const&; - template - constexpr @\exposid{error-value-type}@ error_or(G&& def) &&; + template constexpr @\exposid{error-value-type}@ error_or(G&& def) &&; template constexpr void value_or(U&&) const = delete; @@ -1925,7 +1921,6 @@ \pnum If \tcode{E} is not an lvalue reference type, \tcode{E} shall meet the requirements of \oldconcept{Destructible} (\tref{cpp17.destructible}). - \rSec3[expected.void.cons]{Constructors} \indexlibraryctor{expected}% @@ -1945,7 +1940,6 @@ \end{itemdecl} \begin{itemdescr} - \pnum \effects If \tcode{rhs.has_value()} is \tcode{false}, direct-non-list-initializes \exposid{unex} with \tcode{rhs.error()}. @@ -2231,7 +2225,6 @@ \end{itemdecl} \begin{itemdescr} - \pnum \effects If \tcode{this->has_value() \&\& rhs.has_value()}, no effects. Otherwise, if \tcode{this->has_value()}, equivalent to: \tcode{construct_at(addressof(\exposid{unex}), rhs.\exposid{unex}); \exposid{has_val} = false;} Otherwise, if \tcode{rhs.has_value()}, destroys \exposid{unex} and sets \exposid{has_val} to \tcode{true}. Otherwise, equivalent to \tcode{\exposid{unex} = rhs.\exposid{unex}}. @@ -2545,6 +2538,9 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{U} be \tcode{remove_cvref_t>}. + \pnum \constraints \tcode{is_constructible_v} is \tcode{true}. @@ -2567,6 +2563,9 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{U} be \tcode{remove_cvref_t>}. + \pnum \constraints \tcode{is_constructible_v} is \tcode{true}. @@ -2589,6 +2588,9 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{G} be \tcode{remove_cvref_t>}. + \pnum \mandates \tcode{remove_cvref_t>} is a specialization of \tcode{expected} and its \tcode{value_type} is the same type as \tcode{T}. @@ -2607,6 +2609,9 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{G} be \tcode{remove_cvref_t>}. + \pnum \mandates \tcode{remove_cvref_t>} is a specialization of \tcode{expected} and its \tcode{value_type} is the same type as \tcode{T}. @@ -2669,6 +2674,9 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{G} be \tcode{remove_cv_t>}. + \pnum \mandates \tcode{G} is a valid template argument for \tcode{unexpected} and the declaration \tcode{G g(invoke(std::forward(f), error()));} is well-formed, where \tcode{G} is \tcode{remove_cv_t>}. @@ -2687,6 +2695,9 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{G} be \tcode{remove_cv_t>}. + \pnum \mandates \tcode{G} is a valid template argument for \tcode{unexpected} and the declaration \tcode{G g(invoke(std::forward(f), std::move(error())));} is well-formed, where \tcode{G} is \tcode{remove_cv_t>}. @@ -2753,37 +2764,30 @@ expected() = delete; - constexpr expected(const expected& rhs) noexcept( - is_nothrow_copy_constructible_v); + constexpr expected(const expected& rhs) noexcept(is_nothrow_copy_constructible_v); constexpr expected(expected&& rhs) noexcept(@\seebelow@); template constexpr expected(in_place_t, Args&&...) = delete; template - constexpr explicit(@\seebelow@) - expected(U&& u) noexcept(is_nothrow_constructible_v); + constexpr explicit(@\seebelow@) expected(U&& u) noexcept(is_nothrow_constructible_v); template constexpr expected(U&&) = delete; - template - constexpr explicit(@\seebelow@) expected(const expected& rhs); + template constexpr explicit(@\seebelow@) expected(const expected& rhs); - template - constexpr explicit(@\seebelow@) expected(expected&& rhs); + template constexpr explicit(@\seebelow@) expected(expected&& rhs); - template - constexpr explicit(@\seebelow@) expected(const expected& rhs); + template constexpr explicit(@\seebelow@) expected(const expected& rhs); - template - constexpr explicit(@\seebelow@) expected(expected&& rhs); + template constexpr explicit(@\seebelow@) expected(expected&& rhs); template constexpr explicit(@\seebelow@) expected(const unexpected& e); template constexpr explicit(@\seebelow@) expected(unexpected&& e); - template - constexpr explicit(@\seebelow@) expected(const unexpected& e) noexcept; + template constexpr explicit(@\seebelow@) expected(const unexpected& e) noexcept; template constexpr explicit(@\seebelow@) expected(unexpected&& e) noexcept; @@ -2861,11 +2865,9 @@ template> constexpr remove_cv_t value_or(U&& def) const; - template - constexpr @\exposid{error-value-type}@ error_or(G&& def) const&; + template constexpr @\exposid{error-value-type}@ error_or(G&& def) const&; - template - constexpr @\exposid{error-value-type}@ error_or(G&& def) &&; + template constexpr @\exposid{error-value-type}@ error_or(G&& def) &&; // \ref{expected.ref.monadic}, monadic operations @@ -2895,8 +2897,7 @@ requires(!is_void_v) friend constexpr bool operator==(const expected& x, const expected& y); - template - friend constexpr bool operator==(const expected& x, const T2& val); + template friend constexpr bool operator==(const expected& x, const T2& val); template friend constexpr bool operator==(const expected& x, const unexpected& e); @@ -2923,7 +2924,6 @@ \pnum \tcode{T} shall be an object type that is not an array type, \tcode{in_place_t}, \tcode{unexpect_t}, or a specialization of \tcode{unexpected}. If \tcode{E} is not an lvalue reference type, \tcode{E} shall meet the \oldconcept{Destructible} requirements (\tref{cpp17.destructible}). - \rSec3[expected.ref.cons]{Constructors} \indexlibraryctor{expected}% @@ -2944,7 +2944,6 @@ \end{itemdecl} \begin{itemdescr} - \pnum \effects If \tcode{rhs.has_value()} is \tcode{true}, initializes \exposid{val} with \tcode{rhs.\exposid{val}}, so that \tcode{*this} and \tcode{rhs} refer to the same object; otherwise, initializes \exposid{unex} with \tcode{rhs.\exposid{unex}}. @@ -3205,6 +3204,9 @@ \rSec3[expected.ref.assign]{Assignment} +\pnum +Assignment rebinds: assigning to an \tcode{expected} that holds a value changes which object it refers to. It never assigns through to the referent. + \indexlibrarymember{operator=}{expected}% \begin{itemdecl} constexpr expected& operator=(const expected& rhs) noexcept(is_nothrow_copy_constructible_v && @@ -3213,7 +3215,6 @@ \end{itemdecl} \begin{itemdescr} - \pnum \effects If \tcode{rhs.has_value()} is \tcode{true}: if \tcode{has_value()} is \tcode{true}, assigns \tcode{rhs.\exposid{val}} to \exposid{val}; otherwise destroys \exposid{unex} and initializes \exposid{val} with \tcode{rhs.\exposid{val}}. If \tcode{rhs.has_value()} is \tcode{false}, the error of \tcode{rhs} is assigned to or used to initialize \exposid{unex}, as for the primary template. In every case \tcode{*this} comes to refer to the object \tcode{rhs} refers to, or to hold the error of \tcode{rhs}. @@ -3331,9 +3332,6 @@ \tcode{*\exposid{val}}. \end{itemdescr} -\pnum -Assignment rebinds: assigning to an \tcode{expected} that holds a value changes which object it refers to. It never assigns through to the referent. - \rSec3[expected.ref.swap]{Swap} \indexlibrarymember{swap}{expected}% @@ -3496,6 +3494,9 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{X} be \tcode{remove_cv_t}. + \pnum \constraints \tcode{is_object_v} is \tcode{true} and \tcode{is_array_v} is \tcode{false}. @@ -3552,6 +3553,9 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{U} be \tcode{remove_cvref_t>}. + \pnum \constraints \tcode{is_constructible_v} is \tcode{true}. @@ -3578,6 +3582,9 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{U} be \tcode{remove_cvref_t>}. + \pnum \constraints \tcode{is_constructible_v} is \tcode{true}. @@ -3600,6 +3607,9 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{G} be \tcode{remove_cvref_t>}. + \pnum \mandates \tcode{remove_cvref_t>} is \tcode{expected} for some type \tcode{X}. @@ -3618,6 +3628,9 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{G} be \tcode{remove_cvref_t>}. + \pnum \mandates \tcode{remove_cvref_t>} is \tcode{expected} for some type \tcode{X}. @@ -3672,6 +3685,9 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{G} be \tcode{remove_cv_t>}. + \pnum \mandates \begin{itemize} @@ -3695,6 +3711,9 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{G} be \tcode{remove_cv_t>}. + \pnum \mandates \begin{itemize} diff --git a/papers/wording/fragments/expected.bad.tex b/papers/wording/fragments/expected.bad.tex index 4c436d5e..e76fb8d8 100644 --- a/papers/wording/fragments/expected.bad.tex +++ b/papers/wording/fragments/expected.bad.tex @@ -5,8 +5,8 @@ template class @\libglobal{bad_expected_access}@ : public bad_expected_access { public: - BEMAN_EXPECTED_CONSTEXPR_EXCEPTION explicit bad_expected_access(E e); - BEMAN_EXPECTED_CONSTEXPR_EXCEPTION const char* what() const noexcept override; + explicit bad_expected_access(E e); + const char* what() const noexcept override; constexpr E& error() & noexcept; constexpr const E& error() const& noexcept; constexpr E&& error() && noexcept; diff --git a/papers/wording/fragments/expected.bad.void.tex b/papers/wording/fragments/expected.bad.void.tex index bafa2d27..8389b8f2 100644 --- a/papers/wording/fragments/expected.bad.void.tex +++ b/papers/wording/fragments/expected.bad.void.tex @@ -5,19 +5,19 @@ template<> class @\libglobal{bad_expected_access}@ : public exception { protected: - BEMAN_EXPECTED_CONSTEXPR_EXCEPTION bad_expected_access() noexcept = default; - BEMAN_EXPECTED_CONSTEXPR_EXCEPTION bad_expected_access( + bad_expected_access() noexcept = default; + bad_expected_access(const bad_expected_access&) noexcept = + default; + bad_expected_access(bad_expected_access&&) noexcept = + default; + bad_expected_access& operator=( const bad_expected_access&) noexcept = default; - BEMAN_EXPECTED_CONSTEXPR_EXCEPTION bad_expected_access( + bad_expected_access& operator=( bad_expected_access&&) noexcept = 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; + ~bad_expected_access() = default; public: - BEMAN_EXPECTED_CONSTEXPR_EXCEPTION const char* what() const noexcept override; + const char* what() const noexcept override; }; } \end{codeblock} diff --git a/papers/wording/fragments/expected.expected.tex b/papers/wording/fragments/expected.expected.tex index 7413de25..8e5cb447 100644 --- a/papers/wording/fragments/expected.expected.tex +++ b/papers/wording/fragments/expected.expected.tex @@ -20,22 +20,18 @@ constexpr expected() noexcept(is_nothrow_default_constructible_v); - constexpr expected(const expected& rhs) noexcept( - is_nothrow_copy_constructible_v && is_nothrow_copy_constructible_v); + constexpr expected(const expected& rhs) noexcept(is_nothrow_copy_constructible_v && + is_nothrow_copy_constructible_v); constexpr expected(expected&& rhs) noexcept(@\seebelow@); - template - constexpr explicit(@\seebelow@) expected(const expected& rhs); + template constexpr explicit(@\seebelow@) expected(const expected& rhs); - template - constexpr explicit(@\seebelow@) expected(expected&& rhs); + template constexpr explicit(@\seebelow@) expected(expected&& rhs); - template - constexpr explicit(@\seebelow@) expected(const expected& rhs); + template constexpr explicit(@\seebelow@) expected(const expected& rhs); - template - constexpr explicit(@\seebelow@) expected(expected&& rhs); + template constexpr explicit(@\seebelow@) expected(expected&& rhs); template> constexpr explicit(!is_convertible_v) expected(U&& v); @@ -43,12 +39,10 @@ template constexpr explicit(!is_convertible_v) expected(const unexpected& e); - template - constexpr explicit(!is_convertible_v) expected(unexpected&& e); + template constexpr explicit(!is_convertible_v) expected(unexpected&& e); template - constexpr explicit(!is_convertible_v) - expected(const unexpected& e) noexcept; + constexpr explicit(!is_convertible_v) expected(const unexpected& e) noexcept; template constexpr explicit(!is_convertible_v) expected(unexpected&& e) noexcept; @@ -145,11 +139,9 @@ template> constexpr T value_or(U&& def) &&; - template - constexpr @\exposid{error-value-type}@ error_or(G&& def) const&; + template constexpr @\exposid{error-value-type}@ error_or(G&& def) const&; - template - constexpr @\exposid{error-value-type}@ error_or(G&& def) &&; + template constexpr @\exposid{error-value-type}@ error_or(G&& def) &&; // \ref{expected.object.monadic}, monadic operations @@ -179,8 +171,7 @@ requires(!is_void_v) friend constexpr bool operator==(const expected& x, const expected& y); - template - friend constexpr bool operator==(const expected& x, const T2& val); + template friend constexpr bool operator==(const expected& x, const T2& val); template friend constexpr bool operator==(const expected& x, const unexpected& e); @@ -207,7 +198,6 @@ \pnum When \tcode{T} is not \cv{} \tcode{void}, it shall meet the \oldconcept{Destructible} requirements (\tref{cpp17.destructible}). If \tcode{E} is not an lvalue reference type, \tcode{E} shall meet the \oldconcept{Destructible} requirements. - \rSec3[expected.object.cons]{Constructors} \indexlibraryctor{expected}% @@ -240,7 +230,6 @@ \end{itemdecl} \begin{itemdescr} - \pnum \effects If \tcode{rhs.has_value()} is \tcode{true}, direct-non-list-initializes \exposid{val} with \tcode{*rhs}. Otherwise, direct-non-list-initializes \exposid{unex} with \tcode{rhs.error()}. @@ -576,7 +565,6 @@ \end{itemdecl} \begin{itemdescr} - \pnum \effects If \tcode{has_value()} is \tcode{true}, destroys \exposid{val}, otherwise destroys \exposid{unex}. @@ -597,7 +585,6 @@ \end{itemdecl} \begin{itemdescr} - \pnum \effects If \tcode{this->has_value() \&\& rhs.has_value()}, equivalent to \tcode{\exposid{val} = *rhs}. Otherwise, if \tcode{this->has_value()}, equivalent to \tcode{reinit-expected(\exposid{unex}, \exposid{val}, rhs.error())}. Otherwise, if \tcode{rhs.has_value()}, equivalent to \tcode{reinit-expected(\exposid{val}, \exposid{unex}, *rhs)}. Otherwise, equivalent to \tcode{\exposid{unex} = rhs.\exposid{unex}}. Then, if no exception was thrown, equivalent to: \tcode{\exposid{has_val} = rhs.has_value(); return *this;} When \tcode{E} is an lvalue reference type, each of the cases above that initializes or assigns \exposid{unex} rebinds it: \exposid{unex} comes to refer to the same object as \tcode{rhs}'s error. No previously or subsequently referenced object is assigned through. @@ -988,7 +975,7 @@ \begin{itemdescr} \pnum \constraints -\tcode{is_copy_constructible_v::\exposid{error-value-type}>} is \tcode{true} and \tcode{is_convertible_v::\exposid{error-value-type}>} is \tcode{true}. +\tcode{is_copy_constructible_v::error_value_type>} is \tcode{true} and \tcode{is_convertible_v::error_value_type>} is \tcode{true}. \pnum \mandates @@ -1008,7 +995,7 @@ \begin{itemdescr} \pnum \constraints -\tcode{is_move_constructible_v::\exposid{error-value-type}>} is \tcode{true} and \tcode{is_convertible_v::\exposid{error-value-type}>} is \tcode{true}. +\tcode{is_move_constructible_v::error_value_type>} is \tcode{true} and \tcode{is_convertible_v::error_value_type>} is \tcode{true}. \pnum \mandates @@ -1030,6 +1017,9 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{U} be \tcode{remove_cvref_t>}. + \pnum \constraints \tcode{is_constructible_v} is \tcode{true}. @@ -1052,6 +1042,9 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{U} be \tcode{remove_cvref_t>}. + \pnum \constraints \tcode{is_constructible_v} is \tcode{true}. @@ -1074,6 +1067,9 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{G} be \tcode{remove_cvref_t>}. + \pnum \constraints \tcode{is_constructible_v} is \tcode{true}. @@ -1096,6 +1092,9 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{G} be \tcode{remove_cvref_t>}. + \pnum \constraints \tcode{is_constructible_v} is \tcode{true}. @@ -1154,6 +1153,9 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{G} be \tcode{remove_cv_t>}. + \pnum \constraints \tcode{is_constructible_v} is \tcode{true}. @@ -1181,6 +1183,9 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{G} be \tcode{remove_cv_t>}. + \pnum \constraints \tcode{is_constructible_v} is \tcode{true}. diff --git a/papers/wording/fragments/expected.ref.tex b/papers/wording/fragments/expected.ref.tex index 4aa0bff1..56627b21 100644 --- a/papers/wording/fragments/expected.ref.tex +++ b/papers/wording/fragments/expected.ref.tex @@ -20,37 +20,30 @@ expected() = delete; - constexpr expected(const expected& rhs) noexcept( - is_nothrow_copy_constructible_v); + constexpr expected(const expected& rhs) noexcept(is_nothrow_copy_constructible_v); constexpr expected(expected&& rhs) noexcept(@\seebelow@); template constexpr expected(in_place_t, Args&&...) = delete; template - constexpr explicit(@\seebelow@) - expected(U&& u) noexcept(is_nothrow_constructible_v); + constexpr explicit(@\seebelow@) expected(U&& u) noexcept(is_nothrow_constructible_v); template constexpr expected(U&&) = delete; - template - constexpr explicit(@\seebelow@) expected(const expected& rhs); + template constexpr explicit(@\seebelow@) expected(const expected& rhs); - template - constexpr explicit(@\seebelow@) expected(expected&& rhs); + template constexpr explicit(@\seebelow@) expected(expected&& rhs); - template - constexpr explicit(@\seebelow@) expected(const expected& rhs); + template constexpr explicit(@\seebelow@) expected(const expected& rhs); - template - constexpr explicit(@\seebelow@) expected(expected&& rhs); + template constexpr explicit(@\seebelow@) expected(expected&& rhs); template constexpr explicit(@\seebelow@) expected(const unexpected& e); template constexpr explicit(@\seebelow@) expected(unexpected&& e); - template - constexpr explicit(@\seebelow@) expected(const unexpected& e) noexcept; + template constexpr explicit(@\seebelow@) expected(const unexpected& e) noexcept; template constexpr explicit(@\seebelow@) expected(unexpected&& e) noexcept; @@ -128,11 +121,9 @@ template> constexpr remove_cv_t value_or(U&& def) const; - template - constexpr @\exposid{error-value-type}@ error_or(G&& def) const&; + template constexpr @\exposid{error-value-type}@ error_or(G&& def) const&; - template - constexpr @\exposid{error-value-type}@ error_or(G&& def) &&; + template constexpr @\exposid{error-value-type}@ error_or(G&& def) &&; // \ref{expected.ref.monadic}, monadic operations @@ -162,8 +153,7 @@ requires(!is_void_v) friend constexpr bool operator==(const expected& x, const expected& y); - template - friend constexpr bool operator==(const expected& x, const T2& val); + template friend constexpr bool operator==(const expected& x, const T2& val); template friend constexpr bool operator==(const expected& x, const unexpected& e); @@ -190,7 +180,6 @@ \pnum \tcode{T} shall be an object type that is not an array type, \tcode{in_place_t}, \tcode{unexpect_t}, or a specialization of \tcode{unexpected}. If \tcode{E} is not an lvalue reference type, \tcode{E} shall meet the \oldconcept{Destructible} requirements (\tref{cpp17.destructible}). - \rSec3[expected.ref.cons]{Constructors} \indexlibraryctor{expected}% @@ -211,7 +200,6 @@ \end{itemdecl} \begin{itemdescr} - \pnum \effects If \tcode{rhs.has_value()} is \tcode{true}, initializes \exposid{val} with \tcode{rhs.\exposid{val}}, so that \tcode{*this} and \tcode{rhs} refer to the same object; otherwise, initializes \exposid{unex} with \tcode{rhs.\exposid{unex}}. @@ -472,6 +460,9 @@ \rSec3[expected.ref.assign]{Assignment} +\pnum +Assignment rebinds: assigning to an \tcode{expected} that holds a value changes which object it refers to. It never assigns through to the referent. + \indexlibrarymember{operator=}{expected}% \begin{itemdecl} constexpr expected& operator=(const expected& rhs) noexcept(is_nothrow_copy_constructible_v && @@ -480,7 +471,6 @@ \end{itemdecl} \begin{itemdescr} - \pnum \effects If \tcode{rhs.has_value()} is \tcode{true}: if \tcode{has_value()} is \tcode{true}, assigns \tcode{rhs.\exposid{val}} to \exposid{val}; otherwise destroys \exposid{unex} and initializes \exposid{val} with \tcode{rhs.\exposid{val}}. If \tcode{rhs.has_value()} is \tcode{false}, the error of \tcode{rhs} is assigned to or used to initialize \exposid{unex}, as for the primary template. In every case \tcode{*this} comes to refer to the object \tcode{rhs} refers to, or to hold the error of \tcode{rhs}. @@ -598,9 +588,6 @@ \tcode{*\exposid{val}}. \end{itemdescr} -\pnum -Assignment rebinds: assigning to an \tcode{expected} that holds a value changes which object it refers to. It never assigns through to the referent. - \rSec3[expected.ref.swap]{Swap} \indexlibrarymember{swap}{expected}% @@ -763,6 +750,9 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{X} be \tcode{remove_cv_t}. + \pnum \constraints \tcode{is_object_v} is \tcode{true} and \tcode{is_array_v} is \tcode{false}. @@ -819,6 +809,9 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{U} be \tcode{remove_cvref_t>}. + \pnum \constraints \tcode{is_constructible_v} is \tcode{true}. @@ -845,6 +838,9 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{U} be \tcode{remove_cvref_t>}. + \pnum \constraints \tcode{is_constructible_v} is \tcode{true}. @@ -867,6 +863,9 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{G} be \tcode{remove_cvref_t>}. + \pnum \mandates \tcode{remove_cvref_t>} is \tcode{expected} for some type \tcode{X}. @@ -885,6 +884,9 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{G} be \tcode{remove_cvref_t>}. + \pnum \mandates \tcode{remove_cvref_t>} is \tcode{expected} for some type \tcode{X}. @@ -939,6 +941,9 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{G} be \tcode{remove_cv_t>}. + \pnum \mandates \begin{itemize} @@ -962,6 +967,9 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{G} be \tcode{remove_cv_t>}. + \pnum \mandates \begin{itemize} diff --git a/papers/wording/fragments/expected.unexpected.tex b/papers/wording/fragments/expected.unexpected.tex index d582d8d5..c3196496 100644 --- a/papers/wording/fragments/expected.unexpected.tex +++ b/papers/wording/fragments/expected.unexpected.tex @@ -22,10 +22,8 @@ is_nothrow_constructible_v); template - constexpr explicit unexpected( - in_place_t, initializer_list il, - Args&&... args) noexcept(is_nothrow_constructible_v&, - Args...>); + constexpr explicit unexpected(in_place_t, initializer_list il, Args&&... args) noexcept( + is_nothrow_constructible_v&, Args...>); constexpr unexpected& operator=(const unexpected&) = default; constexpr unexpected& operator=(unexpected&&) = default; @@ -40,19 +38,19 @@ template friend constexpr bool operator==(const unexpected& x, const unexpected& y); - friend constexpr void swap(unexpected& x, - unexpected& y) noexcept(noexcept(x.swap(y))); + friend constexpr void swap(unexpected& x, unexpected& y) noexcept(noexcept(x.swap(y))); private: E @\exposid{unex}@; // \expos }; + + template unexpected(E) -> unexpected; } \end{codeblock} \pnum A program that instantiates the definition of \tcode{unexpected} for a non-object type other than an lvalue reference type, an array type, a specialization of \tcode{unexpected}, or a cv-qualified type is ill-formed. - \rSec3[expected.un.cons]{Constructors} \indexlibraryctor{unexpected}% @@ -82,7 +80,8 @@ \indexlibraryctor{unexpected}% \begin{itemdecl} template - constexpr explicit unexpected(in_place_t, Args&&... args) noexcept(is_nothrow_constructible_v); + constexpr explicit unexpected(in_place_t, + Args&&... args) noexcept(is_nothrow_constructible_v); \end{itemdecl} \begin{itemdescr} @@ -102,8 +101,8 @@ \indexlibraryctor{unexpected}% \begin{itemdecl} template - constexpr explicit unexpected(in_place_t, initializer_list il, - Args&&... args) noexcept(is_nothrow_constructible_v&, Args...>); + constexpr explicit unexpected(in_place_t, initializer_list il, Args&&... args) noexcept( + is_nothrow_constructible_v&, Args...>); \end{itemdecl} \begin{itemdescr} @@ -234,7 +233,6 @@ \pnum A program that instantiates the definition of \tcode{unexpected} for a referenced type that is not an object type, an array type, or a specialization of \tcode{unexpected} is ill-formed. Unlike the primary template, \tcode{E} may be a cv-qualified type. - \indexlibraryctor{unexpected}% \begin{itemdecl} template diff --git a/papers/wording/fragments/expected.void.tex b/papers/wording/fragments/expected.void.tex index 74687377..5aadc8de 100644 --- a/papers/wording/fragments/expected.void.tex +++ b/papers/wording/fragments/expected.void.tex @@ -20,14 +20,12 @@ constexpr expected() noexcept; - constexpr expected(const expected& rhs) noexcept( - is_nothrow_copy_constructible_v); + constexpr expected(const expected& rhs) noexcept(is_nothrow_copy_constructible_v); constexpr expected(expected&& rhs) noexcept(is_nothrow_move_constructible_v); template - constexpr explicit(!is_convertible_v) - expected(const expected& rhs); + constexpr explicit(!is_convertible_v) expected(const expected& rhs); template constexpr explicit(!is_convertible_v) expected(expected&& rhs); @@ -35,12 +33,10 @@ template constexpr explicit(!is_convertible_v) expected(const unexpected& e); - template - constexpr explicit(!is_convertible_v) expected(unexpected&& e); + template constexpr explicit(!is_convertible_v) expected(unexpected&& e); template - constexpr explicit(!is_convertible_v) - expected(const unexpected& e) noexcept; + constexpr explicit(!is_convertible_v) expected(const unexpected& e) noexcept; template constexpr explicit(!is_convertible_v) expected(unexpected&& e) noexcept; @@ -69,8 +65,7 @@ constexpr expected(unexpect_t, initializer_list, Args&&...) = delete; template - constexpr explicit(!is_convertible_v) - expected(const expected& rhs); + constexpr explicit(!is_convertible_v) expected(const expected& rhs); template constexpr explicit(!is_convertible_v) expected(expected&& rhs); @@ -123,11 +118,9 @@ constexpr const E&& error() const&& noexcept; constexpr E&& error() && noexcept; - template - constexpr @\exposid{error-value-type}@ error_or(G&& def) const&; + template constexpr @\exposid{error-value-type}@ error_or(G&& def) const&; - template - constexpr @\exposid{error-value-type}@ error_or(G&& def) &&; + template constexpr @\exposid{error-value-type}@ error_or(G&& def) &&; template constexpr void value_or(U&&) const = delete; @@ -183,7 +176,6 @@ \pnum If \tcode{E} is not an lvalue reference type, \tcode{E} shall meet the requirements of \oldconcept{Destructible} (\tref{cpp17.destructible}). - \rSec3[expected.void.cons]{Constructors} \indexlibraryctor{expected}% @@ -203,7 +195,6 @@ \end{itemdecl} \begin{itemdescr} - \pnum \effects If \tcode{rhs.has_value()} is \tcode{false}, direct-non-list-initializes \exposid{unex} with \tcode{rhs.error()}. @@ -489,7 +480,6 @@ \end{itemdecl} \begin{itemdescr} - \pnum \effects If \tcode{this->has_value() \&\& rhs.has_value()}, no effects. Otherwise, if \tcode{this->has_value()}, equivalent to: \tcode{construct_at(addressof(\exposid{unex}), rhs.\exposid{unex}); \exposid{has_val} = false;} Otherwise, if \tcode{rhs.has_value()}, destroys \exposid{unex} and sets \exposid{has_val} to \tcode{true}. Otherwise, equivalent to \tcode{\exposid{unex} = rhs.\exposid{unex}}. @@ -803,6 +793,9 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{U} be \tcode{remove_cvref_t>}. + \pnum \constraints \tcode{is_constructible_v} is \tcode{true}. @@ -825,6 +818,9 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{U} be \tcode{remove_cvref_t>}. + \pnum \constraints \tcode{is_constructible_v} is \tcode{true}. @@ -847,6 +843,9 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{G} be \tcode{remove_cvref_t>}. + \pnum \mandates \tcode{remove_cvref_t>} is a specialization of \tcode{expected} and its \tcode{value_type} is the same type as \tcode{T}. @@ -865,6 +864,9 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{G} be \tcode{remove_cvref_t>}. + \pnum \mandates \tcode{remove_cvref_t>} is a specialization of \tcode{expected} and its \tcode{value_type} is the same type as \tcode{T}. @@ -927,6 +929,9 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{G} be \tcode{remove_cv_t>}. + \pnum \mandates \tcode{G} is a valid template argument for \tcode{unexpected} and the declaration \tcode{G g(invoke(std::forward(f), error()));} is well-formed, where \tcode{G} is \tcode{remove_cv_t>}. @@ -945,6 +950,9 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{G} be \tcode{remove_cv_t>}. + \pnum \mandates \tcode{G} is a valid template argument for \tcode{unexpected} and the declaration \tcode{G g(invoke(std::forward(f), std::move(error())));} is well-formed, where \tcode{G} is \tcode{remove_cv_t>}. From fee49da074d22f65e48d4c915d20bbddd189dbcd Mon Sep 17 00:00:00 2001 From: Steve Downey Date: Mon, 30 Nov 2026 00:11:46 -0500 Subject: [PATCH 02/24] Author error_or's Constraints so they name error-value-type The out-of-class definitions of the primary template's error_or have to qualify the alias, `typename expected::error_value_type`, and specgen 0.58.0 derives the Constraints from that requires-clause as written: the qualified name is shown as source, not as `\exposid{error-value-type}`. Older specgen showed the exposition-only name. An authored \constraints with the unqualified name replaces the derived one. --validate cannot yet match the two spellings, so the run gains four notes, each a derived conjunct "with no authored constraints counterpart"; they are the same defect and will go when specgen resolves the qualified name. --- include/beman/expected/expected.hpp | 4 ++++ papers/wording/expected.tex | 4 ++-- papers/wording/fragments/expected.expected.tex | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/include/beman/expected/expected.hpp b/include/beman/expected/expected.hpp index d23cac73..9a7c9ace 100644 --- a/include/beman/expected/expected.hpp +++ b/include/beman/expected/expected.hpp @@ -1472,6 +1472,8 @@ 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()` @@ -1486,6 +1488,8 @@ constexpr typename expected::error_value_type expected::error_or(G&& 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`, diff --git a/papers/wording/expected.tex b/papers/wording/expected.tex index 60911673..1cc56127 100644 --- a/papers/wording/expected.tex +++ b/papers/wording/expected.tex @@ -1459,7 +1459,7 @@ \begin{itemdescr} \pnum \constraints -\tcode{is_copy_constructible_v::error_value_type>} is \tcode{true} and \tcode{is_convertible_v::error_value_type>} is \tcode{true}. +\tcode{is_copy_constructible_v<\exposid{error-value-type}>} is \tcode{true} and \tcode{is_convertible_v} is \tcode{true}. \pnum \mandates @@ -1479,7 +1479,7 @@ \begin{itemdescr} \pnum \constraints -\tcode{is_move_constructible_v::error_value_type>} is \tcode{true} and \tcode{is_convertible_v::error_value_type>} is \tcode{true}. +\tcode{is_move_constructible_v<\exposid{error-value-type}>} is \tcode{true} and \tcode{is_convertible_v} is \tcode{true}. \pnum \mandates diff --git a/papers/wording/fragments/expected.expected.tex b/papers/wording/fragments/expected.expected.tex index 8e5cb447..33dd3ce1 100644 --- a/papers/wording/fragments/expected.expected.tex +++ b/papers/wording/fragments/expected.expected.tex @@ -975,7 +975,7 @@ \begin{itemdescr} \pnum \constraints -\tcode{is_copy_constructible_v::error_value_type>} is \tcode{true} and \tcode{is_convertible_v::error_value_type>} is \tcode{true}. +\tcode{is_copy_constructible_v<\exposid{error-value-type}>} is \tcode{true} and \tcode{is_convertible_v} is \tcode{true}. \pnum \mandates @@ -995,7 +995,7 @@ \begin{itemdescr} \pnum \constraints -\tcode{is_move_constructible_v::error_value_type>} is \tcode{true} and \tcode{is_convertible_v::error_value_type>} is \tcode{true}. +\tcode{is_move_constructible_v<\exposid{error-value-type}>} is \tcode{true} and \tcode{is_convertible_v} is \tcode{true}. \pnum \mandates From 2122747eeb1fcd7d7234499441d7783cbc74833f Mon Sep 17 00:00:00 2001 From: Steve Downey Date: Mon, 30 Nov 2026 00:14:04 -0500 Subject: [PATCH 03/24] Let specgen state and_then's U, as the draft does, for the lvalue overloads specgen 0.58 derives the draft's leading "Let U be ..." paragraph from a body-local alias that the Mandates assertions name. The alias in and_then's & body was spelled with T&, so the derived paragraph said `invoke_result_t` for an item that also covers the const& overload, while the docblock restated U in full twice, in the Mandates and in a trailing "where U is ...". The alias is now spelled `decltype((val_))` in both the & and const& bodies, which is the same type in each and is the draft's own spelling, so the derived paragraph reads exactly as [expected.object.monadic] does. The Mandates name U and use the draft's words; the trailing "where" clause is gone. --validate now matches the authored is_same_v conjunct with the derived one and reports one note fewer. This is the pattern for the other twenty "Let" items; only this group is converted here. --- include/beman/expected/expected.hpp | 10 ++++------ papers/wording/expected.tex | 6 +++--- papers/wording/fragments/expected.expected.tex | 6 +++--- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/include/beman/expected/expected.hpp b/include/beman/expected/expected.hpp index 9a7c9ace..9354cf5b 100644 --- a/include/beman/expected/expected.hpp +++ b/include/beman/expected/expected.hpp @@ -1509,17 +1509,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, @@ -1558,7 +1556,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, diff --git a/papers/wording/expected.tex b/papers/wording/expected.tex index 1cc56127..7a83f2e4 100644 --- a/papers/wording/expected.tex +++ b/papers/wording/expected.tex @@ -1502,7 +1502,7 @@ \begin{itemdescr} \pnum -Let \tcode{U} be \tcode{remove_cvref_t>}. +Let \tcode{U} be \tcode{remove_cvref_t>}. \pnum \constraints @@ -1510,11 +1510,11 @@ \pnum \mandates -\tcode{remove_cvref_t>} is a specialization of \tcode{expected} and its \tcode{error_type} is the same type as \tcode{E}. +\tcode{U} is a specialization of \tcode{expected} and \tcode{is_same_v} is \tcode{true}. \pnum \effects -Equivalent to: \tcode{if (has_value()) return invoke(std::forward(f), \exposid{val}); else return U(unexpect, error());} where \tcode{U} is \tcode{remove_cvref_t>}. +Equivalent to: \tcode{if (has_value()) return invoke(std::forward(f), \exposid{val}); else return U(unexpect, error());} \end{itemdescr} \indexlibrarymember{and_then}{expected}% diff --git a/papers/wording/fragments/expected.expected.tex b/papers/wording/fragments/expected.expected.tex index 33dd3ce1..20abf7f2 100644 --- a/papers/wording/fragments/expected.expected.tex +++ b/papers/wording/fragments/expected.expected.tex @@ -1018,7 +1018,7 @@ \begin{itemdescr} \pnum -Let \tcode{U} be \tcode{remove_cvref_t>}. +Let \tcode{U} be \tcode{remove_cvref_t>}. \pnum \constraints @@ -1026,11 +1026,11 @@ \pnum \mandates -\tcode{remove_cvref_t>} is a specialization of \tcode{expected} and its \tcode{error_type} is the same type as \tcode{E}. +\tcode{U} is a specialization of \tcode{expected} and \tcode{is_same_v} is \tcode{true}. \pnum \effects -Equivalent to: \tcode{if (has_value()) return invoke(std::forward(f), \exposid{val}); else return U(unexpect, error());} where \tcode{U} is \tcode{remove_cvref_t>}. +Equivalent to: \tcode{if (has_value()) return invoke(std::forward(f), \exposid{val}); else return U(unexpect, error());} \end{itemdescr} \indexlibrarymember{and_then}{expected}% From 9179a4594c87de5e7a3e63c108126e9c366da985 Mon Sep 17 00:00:00 2001 From: Steve Downey Date: Mon, 30 Nov 2026 00:16:01 -0500 Subject: [PATCH 04/24] Show constexpr where the header writes BEMAN_EXPECTED_CONSTEXPR_EXCEPTION specgen writes a specifier macro as its expansion in the translation unit it parses, and since specgen#377 it does so for a macro the header #undefs at the end, as bad_expected_access.hpp does. What remained was which expansion: the one the standard library specgen's Clang found, which here was the empty one, so nine declarations the draft marks constexpr lost it. SPECGEN_CLANG_ARGS now defines __cpp_lib_constexpr_exceptions as libstdc++ 16 does, so the wording shows constexpr on every machine. The macro appears 0 times in the wording. Against the draft at n5054, [expected.bad] goes from 1 / 3 marks to 1 / 0 (the parameter name left) and [expected.bad.void] from 8 / 8 to 8 / 0 (the `= default`s left). --- Makefile | 7 +++++- papers/wording/expected.tex | 24 +++++++++---------- papers/wording/fragments/expected.bad.tex | 8 +++---- .../wording/fragments/expected.bad.void.tex | 16 ++++++------- 4 files changed, 30 insertions(+), 25 deletions(-) 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/papers/wording/expected.tex b/papers/wording/expected.tex index 7a83f2e4..4f1f9ff6 100644 --- a/papers/wording/expected.tex +++ b/papers/wording/expected.tex @@ -385,8 +385,8 @@ template class @\libglobal{bad_expected_access}@ : public bad_expected_access { public: - explicit bad_expected_access(E e); - const char* what() const noexcept override; + constexpr explicit bad_expected_access(E e); + constexpr const char* what() const noexcept override; constexpr E& error() & noexcept; constexpr const E& error() const& noexcept; constexpr E&& error() && noexcept; @@ -403,7 +403,7 @@ \indexlibraryctor{bad_expected_access}% \begin{itemdecl} -explicit bad_expected_access(E e); +constexpr explicit bad_expected_access(E e); \end{itemdecl} \begin{itemdescr} @@ -414,7 +414,7 @@ \indexlibrarymember{what}{bad_expected_access}% \begin{itemdecl} -const char* what() const noexcept override; +constexpr const char* what() const noexcept override; \end{itemdecl} \begin{itemdescr} @@ -454,26 +454,26 @@ template<> class @\libglobal{bad_expected_access}@ : public exception { protected: - bad_expected_access() noexcept = default; - bad_expected_access(const bad_expected_access&) noexcept = + constexpr bad_expected_access() noexcept = default; + constexpr bad_expected_access(const bad_expected_access&) noexcept = default; - bad_expected_access(bad_expected_access&&) noexcept = + constexpr bad_expected_access(bad_expected_access&&) noexcept = default; - bad_expected_access& operator=( + constexpr bad_expected_access& operator=( const bad_expected_access&) noexcept = default; - bad_expected_access& operator=( + constexpr bad_expected_access& operator=( bad_expected_access&&) noexcept = default; - ~bad_expected_access() = default; + constexpr ~bad_expected_access() = default; public: - const char* what() const noexcept override; + constexpr const char* what() const noexcept override; }; } \end{codeblock} \indexlibrarymember{what}{bad_expected_access}% \begin{itemdecl} -const char* what() const noexcept override; +constexpr const char* what() const noexcept override; \end{itemdecl} \begin{itemdescr} diff --git a/papers/wording/fragments/expected.bad.tex b/papers/wording/fragments/expected.bad.tex index e76fb8d8..c2a8ea7f 100644 --- a/papers/wording/fragments/expected.bad.tex +++ b/papers/wording/fragments/expected.bad.tex @@ -5,8 +5,8 @@ template class @\libglobal{bad_expected_access}@ : public bad_expected_access { public: - explicit bad_expected_access(E e); - const char* what() const noexcept override; + constexpr explicit bad_expected_access(E e); + constexpr const char* what() const noexcept override; constexpr E& error() & noexcept; constexpr const E& error() const& noexcept; constexpr E&& error() && noexcept; @@ -23,7 +23,7 @@ \indexlibraryctor{bad_expected_access}% \begin{itemdecl} -explicit bad_expected_access(E e); +constexpr explicit bad_expected_access(E e); \end{itemdecl} \begin{itemdescr} @@ -34,7 +34,7 @@ \indexlibrarymember{what}{bad_expected_access}% \begin{itemdecl} -const char* what() const noexcept override; +constexpr const char* what() const noexcept override; \end{itemdecl} \begin{itemdescr} diff --git a/papers/wording/fragments/expected.bad.void.tex b/papers/wording/fragments/expected.bad.void.tex index 8389b8f2..c40d0ba6 100644 --- a/papers/wording/fragments/expected.bad.void.tex +++ b/papers/wording/fragments/expected.bad.void.tex @@ -5,26 +5,26 @@ template<> class @\libglobal{bad_expected_access}@ : public exception { protected: - bad_expected_access() noexcept = default; - bad_expected_access(const bad_expected_access&) noexcept = + constexpr bad_expected_access() noexcept = default; + constexpr bad_expected_access(const bad_expected_access&) noexcept = default; - bad_expected_access(bad_expected_access&&) noexcept = + constexpr bad_expected_access(bad_expected_access&&) noexcept = default; - bad_expected_access& operator=( + constexpr bad_expected_access& operator=( const bad_expected_access&) noexcept = default; - bad_expected_access& operator=( + constexpr bad_expected_access& operator=( bad_expected_access&&) noexcept = default; - ~bad_expected_access() = default; + constexpr ~bad_expected_access() = default; public: - const char* what() const noexcept override; + constexpr const char* what() const noexcept override; }; } \end{codeblock} \indexlibrarymember{what}{bad_expected_access}% \begin{itemdecl} -const char* what() const noexcept override; +constexpr const char* what() const noexcept override; \end{itemdecl} \begin{itemdescr} From 80a552e0026f5384a60b101d0566319994b8208f Mon Sep 17 00:00:00 2001 From: Steve Downey Date: Mon, 30 Nov 2026 00:18:47 -0500 Subject: [PATCH 05/24] Show the draft's declarations where the library strengthens them implementation-extras decided that the wording shows the draft's declaration where the implementation declares more, and that nothing changes in the headers until specgen has a marker for it. specgen#385 added `\omit noexcept` and `\omit default`. `\omit noexcept` on the three constructors of unexpected, the default constructor of expected, and the copy constructors and copy assignment operators of expected and expected: each has a conditional noexcept the draft does not, as [res.on.exception.handling] allows. `\omit default` on the six special members of bad_expected_access, which the draft declares without defining. Against the draft at n5054: [expected.bad.void] has no marks, from 8 / 0; [expected.unexpected] 10 / 3, from 16 / 7, the rest parameter names, which #385 left out, a *see below* on swap and a reordering; [expected.expected] 142 / 105, from 153 / 109; [expected.void] 193 / 140, from 196 / 141. --validate is unchanged. --- .../beman/expected/bad_expected_access.hpp | 16 +++-- include/beman/expected/expected.hpp | 5 ++ include/beman/expected/unexpected.hpp | 3 + papers/wording/expected.tex | 61 +++++++------------ .../wording/fragments/expected.bad.void.tex | 14 ++--- .../wording/fragments/expected.expected.tex | 19 ++---- .../wording/fragments/expected.unexpected.tex | 18 ++---- papers/wording/fragments/expected.void.tex | 10 ++- 8 files changed, 63 insertions(+), 83 deletions(-) diff --git a/include/beman/expected/bad_expected_access.hpp b/include/beman/expected/bad_expected_access.hpp index 716416da..2152d249 100644 --- a/include/beman/expected/bad_expected_access.hpp +++ b/include/beman/expected/bad_expected_access.hpp @@ -64,12 +64,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 9354cf5b..8dfbd0a9 100644 --- a/include/beman/expected/expected.hpp +++ b/include/beman/expected/expected.hpp @@ -647,6 +647,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 +658,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 @@ -931,6 +933,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 @@ -2277,6 +2280,7 @@ constexpr expected::expected() noexcept : has_val_(true), void_() {} template constexpr expected::expected(std::in_place_t) noexcept : has_val_(true), void_() {} +//! \omit noexcept //! \constraints //! \effects If `rhs.has_value()` is `false`, direct-non-list-initializes //! `unex` with `rhs.error()`. @@ -2468,6 +2472,7 @@ constexpr expected::~expected() // ============================================================================= // \rSec3[expected.void.assign]{Assignment} +//! \omit noexcept //! \constraints //! \effects If `this->has_value() && rhs.has_value()`, no effects. //! Otherwise, if `this->has_value()`, equivalent to: diff --git a/include/beman/expected/unexpected.hpp b/include/beman/expected/unexpected.hpp index cc5d6af2..3629e864 100644 --- a/include/beman/expected/unexpected.hpp +++ b/include/beman/expected/unexpected.hpp @@ -85,6 +85,7 @@ class unexpected { constexpr unexpected(const unexpected&) = default; constexpr unexpected(unexpected&&) = default; + //! \omit noexcept //! \constraints //! \item `is_same_v, unexpected>` is `false`; and //! \item `is_same_v, in_place_t>` is `false`; and @@ -98,6 +99,7 @@ class unexpected { constexpr explicit unexpected(Err&& e) noexcept(std::is_nothrow_constructible_v) : unex_(std::forward(e)) {} + //! \omit noexcept //! \constraints `is_constructible_v` is `true`. //! \effects Direct-non-list-initializes `unex` with //! `std::forward(args)...`. @@ -108,6 +110,7 @@ class unexpected { Args&&... args) noexcept(std::is_nothrow_constructible_v) : unex_(std::forward(args)...) {} + //! \omit noexcept //! \constraints `is_constructible_v&, Args...>` is //! `true`. //! \effects Direct-non-list-initializes `unex` with `il, diff --git a/papers/wording/expected.tex b/papers/wording/expected.tex index 4f1f9ff6..24647f15 100644 --- a/papers/wording/expected.tex +++ b/papers/wording/expected.tex @@ -65,16 +65,12 @@ constexpr unexpected(const unexpected&) = default; constexpr unexpected(unexpected&&) = default; - template - constexpr explicit unexpected(Err&& e) noexcept(is_nothrow_constructible_v); + template constexpr explicit unexpected(Err&& e); - template - constexpr explicit unexpected(in_place_t, Args&&... args) noexcept( - is_nothrow_constructible_v); + template constexpr explicit unexpected(in_place_t, Args&&... args); template - constexpr explicit unexpected(in_place_t, initializer_list il, Args&&... args) noexcept( - is_nothrow_constructible_v&, Args...>); + constexpr explicit unexpected(in_place_t, initializer_list il, Args&&... args); constexpr unexpected& operator=(const unexpected&) = default; constexpr unexpected& operator=(unexpected&&) = default; @@ -107,7 +103,7 @@ \indexlibraryctor{unexpected}% \begin{itemdecl} template - constexpr explicit unexpected(Err&& e) noexcept(is_nothrow_constructible_v); + constexpr explicit unexpected(Err&& e); \end{itemdecl} \begin{itemdescr} @@ -131,8 +127,7 @@ \indexlibraryctor{unexpected}% \begin{itemdecl} template - constexpr explicit unexpected(in_place_t, - Args&&... args) noexcept(is_nothrow_constructible_v); + constexpr explicit unexpected(in_place_t, Args&&... args); \end{itemdecl} \begin{itemdescr} @@ -152,8 +147,7 @@ \indexlibraryctor{unexpected}% \begin{itemdecl} template - constexpr explicit unexpected(in_place_t, initializer_list il, Args&&... args) noexcept( - is_nothrow_constructible_v&, Args...>); + constexpr explicit unexpected(in_place_t, initializer_list il, Args&&... args); \end{itemdecl} \begin{itemdescr} @@ -454,16 +448,14 @@ template<> class @\libglobal{bad_expected_access}@ : public exception { protected: - constexpr bad_expected_access() noexcept = default; - constexpr bad_expected_access(const bad_expected_access&) noexcept = - default; - constexpr bad_expected_access(bad_expected_access&&) noexcept = - default; + 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 = default; + const bad_expected_access&) noexcept; constexpr bad_expected_access& operator=( - bad_expected_access&&) noexcept = default; - constexpr ~bad_expected_access() = default; + bad_expected_access&&) noexcept; + constexpr ~bad_expected_access(); public: constexpr const char* what() const noexcept override; @@ -502,10 +494,9 @@ // \ref{expected.object.cons}, constructors - constexpr expected() noexcept(is_nothrow_default_constructible_v); + constexpr expected(); - constexpr expected(const expected& rhs) noexcept(is_nothrow_copy_constructible_v && - is_nothrow_copy_constructible_v); + constexpr expected(const expected& rhs); constexpr expected(expected&& rhs) noexcept(@\seebelow@); @@ -563,9 +554,7 @@ // \ref{expected.object.assign}, assignment - constexpr expected& operator=(const expected& rhs) noexcept( - is_nothrow_copy_constructible_v && is_nothrow_copy_assignable_v && - is_nothrow_copy_constructible_v && is_nothrow_copy_assignable_v); + constexpr expected& operator=(const expected& rhs); constexpr expected& operator=(expected&& rhs) noexcept(@\seebelow@); @@ -686,7 +675,7 @@ \indexlibraryctor{expected}% \begin{itemdecl} -constexpr expected() noexcept(is_nothrow_default_constructible_v); +constexpr expected(); \end{itemdecl} \begin{itemdescr} @@ -709,8 +698,7 @@ \indexlibraryctor{expected}% \begin{itemdecl} -constexpr expected(const expected& rhs) noexcept(is_nothrow_copy_constructible_v && - is_nothrow_copy_constructible_v); +constexpr expected(const expected& rhs); \end{itemdecl} \begin{itemdescr} @@ -1062,10 +1050,7 @@ \indexlibrarymember{operator=}{expected}% \begin{itemdecl} -constexpr expected& operator=(const expected& rhs) noexcept(is_nothrow_copy_constructible_v && - is_nothrow_copy_assignable_v && - is_nothrow_copy_constructible_v && - is_nothrow_copy_assignable_v); +constexpr expected& operator=(const expected& rhs); \end{itemdecl} \begin{itemdescr} @@ -1765,7 +1750,7 @@ constexpr expected() noexcept; - constexpr expected(const expected& rhs) noexcept(is_nothrow_copy_constructible_v); + constexpr expected(const expected& rhs); constexpr expected(expected&& rhs) noexcept(is_nothrow_move_constructible_v); @@ -1821,8 +1806,7 @@ // \ref{expected.void.assign}, assignment - constexpr expected& operator=(const expected& rhs) noexcept( - is_nothrow_copy_constructible_v && is_nothrow_copy_assignable_v); + constexpr expected& operator=(const expected& rhs); constexpr expected& operator=(expected&& rhs) noexcept(@\seebelow@); @@ -1936,7 +1920,7 @@ \indexlibraryctor{expected}% \begin{itemdecl} -constexpr expected(const expected& rhs) noexcept(is_nothrow_copy_constructible_v); +constexpr expected(const expected& rhs); \end{itemdecl} \begin{itemdescr} @@ -2220,8 +2204,7 @@ \indexlibrarymember{operator=}{expected}% \begin{itemdecl} -constexpr expected& operator=(const expected& rhs) noexcept(is_nothrow_copy_constructible_v && - is_nothrow_copy_assignable_v); +constexpr expected& operator=(const expected& rhs); \end{itemdecl} \begin{itemdescr} diff --git a/papers/wording/fragments/expected.bad.void.tex b/papers/wording/fragments/expected.bad.void.tex index c40d0ba6..c554f118 100644 --- a/papers/wording/fragments/expected.bad.void.tex +++ b/papers/wording/fragments/expected.bad.void.tex @@ -5,16 +5,14 @@ template<> class @\libglobal{bad_expected_access}@ : public exception { protected: - constexpr bad_expected_access() noexcept = default; - constexpr bad_expected_access(const bad_expected_access&) noexcept = - default; - constexpr bad_expected_access(bad_expected_access&&) noexcept = - default; + 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 = default; + const bad_expected_access&) noexcept; constexpr bad_expected_access& operator=( - bad_expected_access&&) noexcept = default; - constexpr ~bad_expected_access() = default; + bad_expected_access&&) noexcept; + constexpr ~bad_expected_access(); public: constexpr const char* what() const noexcept override; diff --git a/papers/wording/fragments/expected.expected.tex b/papers/wording/fragments/expected.expected.tex index 20abf7f2..c27a940f 100644 --- a/papers/wording/fragments/expected.expected.tex +++ b/papers/wording/fragments/expected.expected.tex @@ -18,10 +18,9 @@ // \ref{expected.object.cons}, constructors - constexpr expected() noexcept(is_nothrow_default_constructible_v); + constexpr expected(); - constexpr expected(const expected& rhs) noexcept(is_nothrow_copy_constructible_v && - is_nothrow_copy_constructible_v); + constexpr expected(const expected& rhs); constexpr expected(expected&& rhs) noexcept(@\seebelow@); @@ -79,9 +78,7 @@ // \ref{expected.object.assign}, assignment - constexpr expected& operator=(const expected& rhs) noexcept( - is_nothrow_copy_constructible_v && is_nothrow_copy_assignable_v && - is_nothrow_copy_constructible_v && is_nothrow_copy_assignable_v); + constexpr expected& operator=(const expected& rhs); constexpr expected& operator=(expected&& rhs) noexcept(@\seebelow@); @@ -202,7 +199,7 @@ \indexlibraryctor{expected}% \begin{itemdecl} -constexpr expected() noexcept(is_nothrow_default_constructible_v); +constexpr expected(); \end{itemdecl} \begin{itemdescr} @@ -225,8 +222,7 @@ \indexlibraryctor{expected}% \begin{itemdecl} -constexpr expected(const expected& rhs) noexcept(is_nothrow_copy_constructible_v && - is_nothrow_copy_constructible_v); +constexpr expected(const expected& rhs); \end{itemdecl} \begin{itemdescr} @@ -578,10 +574,7 @@ \indexlibrarymember{operator=}{expected}% \begin{itemdecl} -constexpr expected& operator=(const expected& rhs) noexcept(is_nothrow_copy_constructible_v && - is_nothrow_copy_assignable_v && - is_nothrow_copy_constructible_v && - is_nothrow_copy_assignable_v); +constexpr expected& operator=(const expected& rhs); \end{itemdecl} \begin{itemdescr} diff --git a/papers/wording/fragments/expected.unexpected.tex b/papers/wording/fragments/expected.unexpected.tex index c3196496..1b68ad8a 100644 --- a/papers/wording/fragments/expected.unexpected.tex +++ b/papers/wording/fragments/expected.unexpected.tex @@ -14,16 +14,12 @@ constexpr unexpected(const unexpected&) = default; constexpr unexpected(unexpected&&) = default; - template - constexpr explicit unexpected(Err&& e) noexcept(is_nothrow_constructible_v); + template constexpr explicit unexpected(Err&& e); - template - constexpr explicit unexpected(in_place_t, Args&&... args) noexcept( - is_nothrow_constructible_v); + template constexpr explicit unexpected(in_place_t, Args&&... args); template - constexpr explicit unexpected(in_place_t, initializer_list il, Args&&... args) noexcept( - is_nothrow_constructible_v&, Args...>); + constexpr explicit unexpected(in_place_t, initializer_list il, Args&&... args); constexpr unexpected& operator=(const unexpected&) = default; constexpr unexpected& operator=(unexpected&&) = default; @@ -56,7 +52,7 @@ \indexlibraryctor{unexpected}% \begin{itemdecl} template - constexpr explicit unexpected(Err&& e) noexcept(is_nothrow_constructible_v); + constexpr explicit unexpected(Err&& e); \end{itemdecl} \begin{itemdescr} @@ -80,8 +76,7 @@ \indexlibraryctor{unexpected}% \begin{itemdecl} template - constexpr explicit unexpected(in_place_t, - Args&&... args) noexcept(is_nothrow_constructible_v); + constexpr explicit unexpected(in_place_t, Args&&... args); \end{itemdecl} \begin{itemdescr} @@ -101,8 +96,7 @@ \indexlibraryctor{unexpected}% \begin{itemdecl} template - constexpr explicit unexpected(in_place_t, initializer_list il, Args&&... args) noexcept( - is_nothrow_constructible_v&, Args...>); + constexpr explicit unexpected(in_place_t, initializer_list il, Args&&... args); \end{itemdecl} \begin{itemdescr} diff --git a/papers/wording/fragments/expected.void.tex b/papers/wording/fragments/expected.void.tex index 5aadc8de..24e1154b 100644 --- a/papers/wording/fragments/expected.void.tex +++ b/papers/wording/fragments/expected.void.tex @@ -20,7 +20,7 @@ constexpr expected() noexcept; - constexpr expected(const expected& rhs) noexcept(is_nothrow_copy_constructible_v); + constexpr expected(const expected& rhs); constexpr expected(expected&& rhs) noexcept(is_nothrow_move_constructible_v); @@ -76,8 +76,7 @@ // \ref{expected.void.assign}, assignment - constexpr expected& operator=(const expected& rhs) noexcept( - is_nothrow_copy_constructible_v && is_nothrow_copy_assignable_v); + constexpr expected& operator=(const expected& rhs); constexpr expected& operator=(expected&& rhs) noexcept(@\seebelow@); @@ -191,7 +190,7 @@ \indexlibraryctor{expected}% \begin{itemdecl} -constexpr expected(const expected& rhs) noexcept(is_nothrow_copy_constructible_v); +constexpr expected(const expected& rhs); \end{itemdecl} \begin{itemdescr} @@ -475,8 +474,7 @@ \indexlibrarymember{operator=}{expected}% \begin{itemdecl} -constexpr expected& operator=(const expected& rhs) noexcept(is_nothrow_copy_constructible_v && - is_nothrow_copy_assignable_v); +constexpr expected& operator=(const expected& rhs); \end{itemdecl} \begin{itemdescr} From 1346236127ffd1de0f49d58777fa34c7ad716415 Mon Sep 17 00:00:00 2001 From: Steve Downey Date: Mon, 30 Nov 2026 00:19:44 -0500 Subject: [PATCH 06/24] Record the specgen 0.58.0 round in the plan macro-specifiers and implementation-extras are done; the deduction guide and the section-prose order came with specgen alone. The two defects found are in the specgen-pin Log with what was done about each, and derived-let opens the question of how the monadic operations state U and G now that specgen derives the binding. --- docs/plan/specgen-catchup.md | 74 +++++++++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-) diff --git a/docs/plan/specgen-catchup.md b/docs/plan/specgen-catchup.md index 0de815a6..93162dd2 100644 --- a/docs/plan/specgen-catchup.md +++ b/docs/plan/specgen-catchup.md @@ -25,7 +25,12 @@ 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. What else that unblocks is +in the [specgen-pin](#specgen-pin) Log entry for the day. --- @@ -505,6 +510,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 +597,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 @@ -967,6 +987,14 @@ 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 @@ -986,6 +1014,10 @@ what the option is for. **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. ### unchanged-wording-source @@ -1163,6 +1195,30 @@ 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.** OPEN +**Recommendation.** 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. 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. +**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. + ### specgen-pin **Question.** How is the specgen version fixed and recorded? @@ -1181,6 +1237,22 @@ 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. ## Requests to specgen From 79f46429337b5f81e9ad9df7800a322921f2fb57 Mon Sep 17 00:00:00 2001 From: Steve Downey Date: Mon, 30 Nov 2026 00:47:06 -0500 Subject: [PATCH 07/24] Let specgen state U and G in the rest of the monadic operations Carries derived-let through the monadic operations of all three classes, and value_or of expected, as the lvalue and_then of the primary template already was. The body aliases are spelled as the draft binds them where that is the same type: `decltype((val_))` and `decltype(std::move(val_))` for U in the primary template, and `decltype(error())` for G in the lvalue overloads of all three. In expected, U stays `T&`, which is right for every overload. The rvalue G aliases keep `E&&`: for a reference E, `decltype(std::move(error()))` is an rvalue reference where the call passes an lvalue, so the draft's spelling would name a different type. The authored Mandates name U and G, and every trailing "where U is" is gone. transform and transform_error named the result `expected` U, and the error type G2, which contradicted the derived binding; they now use the draft's U and G, with an authored "Let" for transform, whose assertions are not leading and so derive nothing. value_or names X. --validate reports 105 notes, from 110; none is new. Against the draft at n5054, [expected.expected] is 130 / 96, 45 / 60 marks, from 142 / 105, 45 / 62, and [expected.void] 161 / 128, 36 / 37, from 193 / 140, 36 / 39. --- include/beman/expected/expected.hpp | 197 ++++++++---------- papers/wording/expected.tex | 104 +++++---- .../wording/fragments/expected.expected.tex | 32 +-- papers/wording/fragments/expected.ref.tex | 38 ++-- papers/wording/fragments/expected.void.tex | 34 +-- 5 files changed, 207 insertions(+), 198 deletions(-) diff --git a/include/beman/expected/expected.hpp b/include/beman/expected/expected.hpp index 8dfbd0a9..396af487 100644 --- a/include/beman/expected/expected.hpp +++ b/include/beman/expected/expected.hpp @@ -1533,18 +1533,16 @@ constexpr auto expected::and_then(F&& f) & { //! \group monadic-and-then-rval //! \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(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, @@ -1574,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, @@ -1586,16 +1584,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"); @@ -1607,12 +1603,10 @@ 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(error()));` template template requires std::is_constructible_v @@ -1631,7 +1625,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"); @@ -1655,17 +1649,16 @@ constexpr auto expected::or_else(F&& f) const&& { } //! \group monadic-transform-lval +//! Let `U` be `remove_cv_t>`. //! \constraints `is_constructible_v` is `true`. -//! \effects Equivalent to: `if (!has_value()) return U(unexpect, -//! error()); else return expected(in_place, -//! invoke(std::forward(f), val));` where `U2` is -//! `remove_cv_t>` and `U` is -//! `expected`. +//! \effects Equivalent to: `if (!has_value()) return expected(unexpect, error()); else return expected(in_place, +//! invoke(std::forward(f), val));` template template requires std::is_constructible_v constexpr auto expected::transform(F&& f) & { - using U = std::remove_cv_t>; + using U = std::remove_cv_t>; if constexpr (!std::is_void_v) { static_assert(!std::is_array_v, "transform: U must not be an array type"); static_assert(!std::is_same_v, std::in_place_t>, "transform: U must not be in_place_t"); @@ -1687,18 +1680,17 @@ constexpr auto expected::transform(F&& f) & { } //! \group monadic-transform-rval +//! Let `U` be `remove_cv_t>`. //! \constraints `is_constructible_v` is //! `true`. -//! \effects Equivalent to: `if (!has_value()) return -//! U(unexpect, std::move(error())); else return expected(in_place, invoke(std::forward(f), std::move(val)));` where `U2` -//! is `remove_cv_t>` and `U` -//! is `expected`. +//! \effects Equivalent to: `if (!has_value()) return expected(unexpect, std::move(error())); else return expected(in_place, +//! invoke(std::forward(f), std::move(val)));` template template requires std::is_constructible_v constexpr auto expected::transform(F&& f) && { - using U = std::remove_cv_t>; + using U = std::remove_cv_t>; if constexpr (!std::is_void_v) { static_assert(!std::is_array_v, "transform: U must not be an array type"); static_assert(!std::is_same_v, std::in_place_t>, "transform: U must not be in_place_t"); @@ -1724,7 +1716,7 @@ template template requires std::is_constructible_v constexpr auto expected::transform(F&& f) const& { - using U = std::remove_cv_t>; + using U = std::remove_cv_t>; if constexpr (!std::is_void_v) { static_assert(!std::is_array_v, "transform: U must not be an array type"); static_assert(!std::is_same_v, std::in_place_t>, "transform: U must not be in_place_t"); @@ -1750,7 +1742,7 @@ template template requires std::is_constructible_v constexpr auto expected::transform(F&& f) const&& { - using U = std::remove_cv_t>; + using U = std::remove_cv_t>; if constexpr (!std::is_void_v) { static_assert(!std::is_array_v, "transform: U must not be an array type"); static_assert(!std::is_same_v, std::in_place_t>, "transform: U must not be in_place_t"); @@ -1773,15 +1765,14 @@ constexpr auto expected::transform(F&& f) const&& { //! \group monadic-transform-error-lval //! \constraints `is_constructible_v` is `true`. -//! \effects Equivalent to: `if (has_value()) return G(in_place, val); else -//! return expected(unexpect, invoke(std::forward(f), -//! error()));` where `G2` is `remove_cv_t>` and `G` is `expected`. +//! \effects Equivalent to: `if (has_value()) return expected(in_place, val); else return expected(unexpect, +//! invoke(std::forward(f), error()));` template template requires std::is_constructible_v constexpr auto expected::transform_error(F&& f) & { - using G = std::remove_cv_t>; + using G = std::remove_cv_t>; static_assert(std::is_object_v, "transform_error: G must be an object type"); static_assert(!std::is_array_v, "transform_error: G must not be an array type"); static_assert(std::is_same_v>, "transform_error: G must not be cv-qualified"); @@ -1795,11 +1786,9 @@ constexpr auto expected::transform_error(F&& f) & { //! \group monadic-transform-error-rval //! \constraints `is_constructible_v` is //! `true`. -//! \effects Equivalent to: `if (has_value()) return G(in_place, -//! std::move(val)); else return expected(unexpect, -//! invoke(std::forward(f), std::move(error())));` where `G2` is -//! `remove_cv_t>` and -//! `G` is `expected`. +//! \effects Equivalent to: `if (has_value()) return expected(in_place, std::move(val)); else return expected(unexpect, +//! invoke(std::forward(f), std::move(error())));` template template requires std::is_constructible_v @@ -1820,7 +1809,7 @@ template template requires std::is_constructible_v constexpr auto expected::transform_error(F&& f) const& { - using G = std::remove_cv_t>; + using G = std::remove_cv_t>; static_assert(std::is_object_v, "transform_error: G must be an object type"); static_assert(!std::is_array_v, "transform_error: G must not be an array type"); static_assert(std::is_same_v>, "transform_error: G must not be cv-qualified"); @@ -2786,11 +2775,10 @@ constexpr typename expected::error_value_type expected::error_ //! \group void-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)); else return U(unexpect, error());` where -//! `U` is `remove_cvref_t>`. +//! invoke(std::forward(f)); else return U(unexpect, error());` template template requires std::is_constructible_v @@ -2808,11 +2796,11 @@ constexpr auto expected::and_then(F&& f) & { //! \group void-monadic-and-then-rval //! \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)); else return U(unexpect, -//! std::move(error()));` where `U` is `remove_cvref_t>`. +//! std::move(error()));` template template requires std::is_constructible_v @@ -2858,16 +2846,14 @@ constexpr auto expected::and_then(F&& f) const&& { } //! \group void-monadic-or-else-lval -//! \mandates `remove_cvref_t>` is a -//! specialization of `expected` and its `value_type` is the same type as -//! `T`. +//! \mandates `G` is a specialization of `expected` and its `value_type` is +//! the same type as `T`. //! \effects Equivalent to: `if (has_value()) return G(); else return -//! invoke(std::forward(f), error());` where `G` is -//! `remove_cvref_t>`. +//! invoke(std::forward(f), error());` template template 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 with the same value_type"); @@ -2877,12 +2863,10 @@ constexpr auto expected::or_else(F&& f) & { } //! \group void-monadic-or-else-rval -//! \mandates `remove_cvref_t>` is a specialization of `expected` and -//! its `value_type` is the same type as `T`. +//! \mandates `G` is a specialization of `expected` and its `value_type` is +//! the same type as `T`. //! \effects Equivalent to: `if (has_value()) return G(); else return -//! invoke(std::forward(f), std::move(error()));` where `G` is -//! `remove_cvref_t>`. +//! invoke(std::forward(f), std::move(error()));` template template constexpr auto expected::or_else(F&& f) && { @@ -2899,7 +2883,7 @@ constexpr auto expected::or_else(F&& f) && { template template 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 with the same value_type"); @@ -2922,9 +2906,9 @@ constexpr auto expected::or_else(F&& f) const&& { } //! \group void-monadic-transform-lval +//! Let `U` be `remove_cv_t>`. //! \constraints `is_constructible_v` is `true`. -//! \mandates `U` is a valid value type for `expected`, where `U` is -//! `remove_cv_t>`. +//! \mandates `U` is a valid value type for `expected`. //! \effects If `has_value()` is `false`, returns `expected(unexpect, //! error())`. Otherwise, if `is_void_v` is `false`, returns an //! `expected` object whose `has_val` member is `true` and `val` @@ -2957,10 +2941,10 @@ constexpr auto expected::transform(F&& f) & { } //! \group void-monadic-transform-rval +//! Let `U` be `remove_cv_t>`. //! \constraints `is_constructible_v` is //! `true`. -//! \mandates `U` is a valid value type for `expected`, where `U` is -//! `remove_cv_t>`. +//! \mandates `U` is a valid value type for `expected`. //! \effects If `has_value()` is `false`, returns `expected(unexpect, //! std::move(error()))`. Otherwise, if `is_void_v` is `false`, returns //! an `expected` object whose `has_val` member is `true` and `val` @@ -3047,8 +3031,7 @@ constexpr auto expected::transform(F&& f) const&& { //! \group void-monadic-transform-error-lval //! \mandates `G` is a valid template argument for `unexpected` and the //! declaration `G g(invoke(std::forward(f), error()));` is -//! well-formed, where `G` is `remove_cv_t>`. +//! well-formed. //! \returns If `has_value()` is `true`, `expected()`; otherwise, an //! `expected` object whose `has_val` member is `false` and `unex` //! member is direct-non-list-initialized with `invoke(std::forward(f), @@ -3056,7 +3039,7 @@ constexpr auto expected::transform(F&& f) const&& { template template constexpr auto expected::transform_error(F&& f) & { - using G = std::remove_cv_t>; + using G = std::remove_cv_t>; static_assert(std::is_object_v, "transform_error: G must be an object type"); static_assert(!std::is_array_v, "transform_error: G must not be an array type"); static_assert(std::is_same_v>, "transform_error: G must not be cv-qualified"); @@ -3070,8 +3053,7 @@ constexpr auto expected::transform_error(F&& f) & { //! \group void-monadic-transform-error-rval //! \mandates `G` is a valid template argument for `unexpected` and the //! declaration `G g(invoke(std::forward(f), std::move(error())));` is -//! well-formed, where `G` is `remove_cv_t>`. +//! well-formed. //! \returns If `has_value()` is `true`, `expected()`; otherwise, an //! `expected` object whose `has_val` member is `false` and `unex` //! member is direct-non-list-initialized with `invoke(std::forward(f), @@ -3094,7 +3076,7 @@ constexpr auto expected::transform_error(F&& f) && { template template constexpr auto expected::transform_error(F&& f) const& { - using G = std::remove_cv_t>; + using G = std::remove_cv_t>; static_assert(std::is_object_v, "transform_error: G must be an object type"); static_assert(!std::is_array_v, "transform_error: G must not be an array type"); static_assert(std::is_same_v>, "transform_error: G must not be cv-qualified"); @@ -4121,11 +4103,11 @@ constexpr E&& expected::error() && noexcept { return std::move(unex_).error(); } -//! \mandates `is_convertible_v>` and -//! `is_convertible_v>` are `true`. -//! \returns `has_value() ? static_cast>(*val) : -//! static_cast>(std::forward(def))`. The result is an -//! object, never a reference. +//! \mandates `is_convertible_v` and `is_convertible_v` are +//! `true`. +//! \returns `has_value() ? static_cast(*val) : +//! static_cast(std::forward(def))`. The result is an object, never a +//! reference. template template requires(std::is_object_v && !std::is_array_v) @@ -4167,11 +4149,10 @@ constexpr typename expected::error_value_type expected::error_or(G //! \group ref-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>`. //! \remarks The member templates `and_then`, `or_else`, `transform`, and //! `transform_error` behave as specified for the primary template, with //! one difference: the value is passed to the callable as `T&` for every @@ -4195,12 +4176,11 @@ constexpr auto expected::and_then(F&& f) & { //! \group ref-monadic-and-then-rval //! \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, -//! std::move(error()));` where `U` is `remove_cvref_t>`. +//! std::move(error()));` template template requires std::is_constructible_v @@ -4246,15 +4226,13 @@ constexpr auto expected::and_then(F&& f) const&& { } //! \group ref-monadic-or-else-lval -//! \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(*val); else return -//! invoke(std::forward(f), error());` where `G` is -//! `remove_cvref_t>`. +//! invoke(std::forward(f), error());` template template 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"); @@ -4264,11 +4242,9 @@ constexpr auto expected::or_else(F&& f) & { } //! \group ref-monadic-or-else-rval -//! \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(*val); else return -//! invoke(std::forward(f), std::move(error()));` where `G` is -//! `remove_cvref_t>`. +//! invoke(std::forward(f), std::move(error()));` template template constexpr auto expected::or_else(F&& f) && { @@ -4285,7 +4261,7 @@ constexpr auto expected::or_else(F&& f) && { template template 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"); @@ -4308,11 +4284,11 @@ constexpr auto expected::or_else(F&& f) const&& { } //! \group ref-monadic-transform-lval +//! Let `U` be `remove_cv_t>`. //! \constraints `is_constructible_v` is `true`. -//! \effects Equivalent to: `if (!has_value()) return U(unexpect, -//! error()); else return expected(in_place, -//! invoke(std::forward(f), *val));` where `U2` is -//! `remove_cv_t>` and `U` is `expected`. +//! \effects Equivalent to: `if (!has_value()) return expected(unexpect, error()); else return expected(in_place, +//! invoke(std::forward(f), *val));` template template requires std::is_constructible_v @@ -4339,12 +4315,12 @@ constexpr auto expected::transform(F&& f) & { } //! \group ref-monadic-transform-rval +//! Let `U` be `remove_cv_t>`. //! \constraints `is_constructible_v` is //! `true`. -//! \effects Equivalent to: `if (!has_value()) return U(unexpect, -//! std::move(error())); else return expected(in_place, -//! invoke(std::forward(f), *val));` where `U2` is -//! `remove_cv_t>` and `U` is `expected`. +//! \effects Equivalent to: `if (!has_value()) return expected(unexpect, std::move(error())); else return expected(in_place, +//! invoke(std::forward(f), *val));` template template requires std::is_constructible_v @@ -4423,14 +4399,13 @@ constexpr auto expected::transform(F&& f) const&& { } //! \group ref-monadic-transform-error-lval -//! \effects Equivalent to: `if (has_value()) return G(*val); else return -//! expected(unexpect, invoke(std::forward(f), error()));` -//! where `G2` is `remove_cv_t>` and -//! `G` is `expected`. +//! \effects Equivalent to: `if (has_value()) return expected(*val); +//! else return expected(unexpect, invoke(std::forward(f), +//! error()));` template template constexpr auto expected::transform_error(F&& f) & { - using G = std::remove_cv_t>; + using G = std::remove_cv_t>; static_assert(std::is_object_v, "transform_error: G must be an object type"); static_assert(!std::is_array_v, "transform_error: G must not be an array type"); static_assert(std::is_same_v>, "transform_error: G must not be cv-qualified"); @@ -4442,11 +4417,9 @@ constexpr auto expected::transform_error(F&& f) & { } //! \group ref-monadic-transform-error-rval -//! \effects Equivalent to: `if (has_value()) return G(*val); else return -//! expected(unexpect, invoke(std::forward(f), -//! std::move(error())));` where `G2` is -//! `remove_cv_t>` and -//! `G` is `expected`. +//! \effects Equivalent to: `if (has_value()) return expected(*val); +//! else return expected(unexpect, invoke(std::forward(f), +//! std::move(error())));` template template constexpr auto expected::transform_error(F&& f) && { @@ -4465,7 +4438,7 @@ constexpr auto expected::transform_error(F&& f) && { template template constexpr auto expected::transform_error(F&& f) const& { - using G = std::remove_cv_t>; + using G = std::remove_cv_t>; static_assert(std::is_object_v, "transform_error: G must be an object type"); static_assert(!std::is_array_v, "transform_error: G must not be an array type"); static_assert(std::is_same_v>, "transform_error: G must not be cv-qualified"); diff --git a/papers/wording/expected.tex b/papers/wording/expected.tex index 24647f15..31252cec 100644 --- a/papers/wording/expected.tex +++ b/papers/wording/expected.tex @@ -1512,7 +1512,7 @@ \begin{itemdescr} \pnum -Let \tcode{U} be \tcode{remove_cvref_t>}. +Let \tcode{U} be \tcode{remove_cvref_t>}. \pnum \constraints @@ -1520,11 +1520,11 @@ \pnum \mandates -\tcode{remove_cvref_t>} is a specialization of \tcode{expected} and its \tcode{error_type} is the same type as \tcode{E}. +\tcode{U} is a specialization of \tcode{expected} and \tcode{is_same_v} is \tcode{true}. \pnum \effects -Equivalent to: \tcode{if (has_value()) return invoke(std::forward(f), std::move(\exposid{val})); else return U(unexpect, std::move(error()));} where \tcode{U} is \tcode{remove_cvref_t>}. +Equivalent to: \tcode{if (has_value()) return invoke(std::forward(f), std::move(\exposid{val})); else return U(unexpect, std::move(error()));} \end{itemdescr} \indexlibrarymember{or_else}{expected}% @@ -1537,7 +1537,7 @@ \begin{itemdescr} \pnum -Let \tcode{G} be \tcode{remove_cvref_t>}. +Let \tcode{G} be \tcode{remove_cvref_t>}. \pnum \constraints @@ -1545,11 +1545,11 @@ \pnum \mandates -\tcode{remove_cvref_t>} is \tcode{expected} for some type \tcode{X}. +\tcode{G} is \tcode{expected} for some type \tcode{X}. \pnum \effects -Equivalent to: \tcode{if (has_value()) return G(in_place, \exposid{val}); else return invoke(std::forward(f), error());} where \tcode{G} is \tcode{remove_cvref_t>}. +Equivalent to: \tcode{if (has_value()) return G(in_place, \exposid{val}); else return invoke(std::forward(f), error());} \end{itemdescr} \indexlibrarymember{or_else}{expected}% @@ -1570,11 +1570,11 @@ \pnum \mandates -\tcode{remove_cvref_t>} is \tcode{expected} for some type \tcode{X}. +\tcode{G} is \tcode{expected} for some type \tcode{X}. \pnum \effects -Equivalent to: \tcode{if (has_value()) return G(in_place, std::move(\exposid{val})); else return invoke(std::forward(f), std::move(error()));} where \tcode{G} is \tcode{remove_cvref_t>}. +Equivalent to: \tcode{if (has_value()) return G(in_place, std::move(\exposid{val})); else return invoke(std::forward(f), std::move(error()));} \end{itemdescr} \indexlibrarymember{transform}{expected}% @@ -1586,13 +1586,16 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{U} be \tcode{remove_cv_t>}. + \pnum \constraints \tcode{is_constructible_v} is \tcode{true}. \pnum \effects -Equivalent to: \tcode{if (!has_value()) return U(unexpect, error()); else return expected(in_place, invoke(std::forward(f), \exposid{val}));} where \tcode{U2} is \tcode{remove_cv_t>} and \tcode{U} is \tcode{expected}. +Equivalent to: \tcode{if (!has_value()) return expected(unexpect, error()); else return expected(in_place, invoke(std::forward(f), \exposid{val}));} \end{itemdescr} \indexlibrarymember{transform}{expected}% @@ -1604,13 +1607,16 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{U} be \tcode{remove_cv_t>}. + \pnum \constraints \tcode{is_constructible_v} is \tcode{true}. \pnum \effects -Equivalent to: \tcode{if (!has_value()) return U(unexpect, std::move(error())); else return expected(in_place, invoke(std::forward(f), std::move(\exposid{val})));} where \tcode{U2} is \tcode{remove_cv_t>} and \tcode{U} is \tcode{expected}. +Equivalent to: \tcode{if (!has_value()) return expected(unexpect, std::move(error())); else return expected(in_place, invoke(std::forward(f), std::move(\exposid{val})));} \end{itemdescr} \indexlibrarymember{transform_error}{expected}% @@ -1623,7 +1629,7 @@ \begin{itemdescr} \pnum -Let \tcode{G} be \tcode{remove_cv_t>}. +Let \tcode{G} be \tcode{remove_cv_t>}. \pnum \constraints @@ -1640,7 +1646,7 @@ \pnum \effects -Equivalent to: \tcode{if (has_value()) return G(in_place, \exposid{val}); else return expected(unexpect, invoke(std::forward(f), error()));} where \tcode{G2} is \tcode{remove_cv_t>} and \tcode{G} is \tcode{expected}. +Equivalent to: \tcode{if (has_value()) return expected(in_place, \exposid{val}); else return expected(unexpect, invoke(std::forward(f), error()));} \end{itemdescr} \indexlibrarymember{transform_error}{expected}% @@ -1670,7 +1676,7 @@ \pnum \effects -Equivalent to: \tcode{if (has_value()) return G(in_place, std::move(\exposid{val})); else return expected(unexpect, invoke(std::forward(f), std::move(error())));} where \tcode{G2} is \tcode{remove_cv_t>} and \tcode{G} is \tcode{expected}. +Equivalent to: \tcode{if (has_value()) return expected(in_place, std::move(\exposid{val})); else return expected(unexpect, invoke(std::forward(f), std::move(error())));} \end{itemdescr} \rSec3[expected.object.eq]{Equality operators} @@ -2530,11 +2536,11 @@ \pnum \mandates -\tcode{remove_cvref_t>} is a specialization of \tcode{expected} and its \tcode{error_type} is the same type as \tcode{E}. +\tcode{U} is a specialization of \tcode{expected} and \tcode{is_same_v} is \tcode{true}. \pnum \effects -Equivalent to: \tcode{if (has_value()) return invoke(std::forward(f)); else return U(unexpect, error());} where \tcode{U} is \tcode{remove_cvref_t>}. +Equivalent to: \tcode{if (has_value()) return invoke(std::forward(f)); else return U(unexpect, error());} \end{itemdescr} \indexlibrarymember{and_then}{expected}% @@ -2555,11 +2561,11 @@ \pnum \mandates -\tcode{remove_cvref_t>} is a specialization of \tcode{expected} and its \tcode{error_type} is the same type as \tcode{E}. +\tcode{U} is a specialization of \tcode{expected} and \tcode{is_same_v} is \tcode{true}. \pnum \effects -Equivalent to: \tcode{if (has_value()) return invoke(std::forward(f)); else return U(unexpect, std::move(error()));} where \tcode{U} is \tcode{remove_cvref_t>}. +Equivalent to: \tcode{if (has_value()) return invoke(std::forward(f)); else return U(unexpect, std::move(error()));} \end{itemdescr} \indexlibrarymember{or_else}{expected}% @@ -2572,15 +2578,15 @@ \begin{itemdescr} \pnum -Let \tcode{G} be \tcode{remove_cvref_t>}. +Let \tcode{G} be \tcode{remove_cvref_t>}. \pnum \mandates -\tcode{remove_cvref_t>} is a specialization of \tcode{expected} and its \tcode{value_type} is the same type as \tcode{T}. +\tcode{G} is a specialization of \tcode{expected} and its \tcode{value_type} is the same type as \tcode{T}. \pnum \effects -Equivalent to: \tcode{if (has_value()) return G(); else return invoke(std::forward(f), error());} where \tcode{G} is \tcode{remove_cvref_t>}. +Equivalent to: \tcode{if (has_value()) return G(); else return invoke(std::forward(f), error());} \end{itemdescr} \indexlibrarymember{or_else}{expected}% @@ -2597,11 +2603,11 @@ \pnum \mandates -\tcode{remove_cvref_t>} is a specialization of \tcode{expected} and its \tcode{value_type} is the same type as \tcode{T}. +\tcode{G} is a specialization of \tcode{expected} and its \tcode{value_type} is the same type as \tcode{T}. \pnum \effects -Equivalent to: \tcode{if (has_value()) return G(); else return invoke(std::forward(f), std::move(error()));} where \tcode{G} is \tcode{remove_cvref_t>}. +Equivalent to: \tcode{if (has_value()) return G(); else return invoke(std::forward(f), std::move(error()));} \end{itemdescr} \indexlibrarymember{transform}{expected}% @@ -2613,13 +2619,16 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{U} be \tcode{remove_cv_t>}. + \pnum \constraints \tcode{is_constructible_v} is \tcode{true}. \pnum \mandates -\tcode{U} is a valid value type for \tcode{expected}, where \tcode{U} is \tcode{remove_cv_t>}. +\tcode{U} is a valid value type for \tcode{expected}. \pnum \effects @@ -2635,13 +2644,16 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{U} be \tcode{remove_cv_t>}. + \pnum \constraints \tcode{is_constructible_v} is \tcode{true}. \pnum \mandates -\tcode{U} is a valid value type for \tcode{expected}, where \tcode{U} is \tcode{remove_cv_t>}. +\tcode{U} is a valid value type for \tcode{expected}. \pnum \effects @@ -2658,11 +2670,11 @@ \begin{itemdescr} \pnum -Let \tcode{G} be \tcode{remove_cv_t>}. +Let \tcode{G} be \tcode{remove_cv_t>}. \pnum \mandates -\tcode{G} is a valid template argument for \tcode{unexpected} and the declaration \tcode{G g(invoke(std::forward(f), error()));} is well-formed, where \tcode{G} is \tcode{remove_cv_t>}. +\tcode{G} is a valid template argument for \tcode{unexpected} and the declaration \tcode{G g(invoke(std::forward(f), error()));} is well-formed. \pnum \returns @@ -2683,7 +2695,7 @@ \pnum \mandates -\tcode{G} is a valid template argument for \tcode{unexpected} and the declaration \tcode{G g(invoke(std::forward(f), std::move(error())));} is well-formed, where \tcode{G} is \tcode{remove_cv_t>}. +\tcode{G} is a valid template argument for \tcode{unexpected} and the declaration \tcode{G g(invoke(std::forward(f), std::move(error())));} is well-formed. \pnum \returns @@ -3486,11 +3498,11 @@ \pnum \mandates -\tcode{is_convertible_v>} and \tcode{is_convertible_v>} are \tcode{true}. +\tcode{is_convertible_v} and \tcode{is_convertible_v} are \tcode{true}. \pnum \returns -\tcode{has_value() ? static_cast>(*\exposid{val}) : static_cast>(std::forward(def))}. The result is an object, never a reference. +\tcode{has_value() ? static_cast(*\exposid{val}) : static_cast(std::forward(def))}. The result is an object, never a reference. \end{itemdescr} \indexlibrarymember{error_or}{expected}% @@ -3545,11 +3557,11 @@ \pnum \mandates -\tcode{remove_cvref_t>} is a specialization of \tcode{expected} and its \tcode{error_type} is the same type as \tcode{E}. +\tcode{U} is a specialization of \tcode{expected} and \tcode{is_same_v} is \tcode{true}. \pnum \effects -Equivalent to: \tcode{if (has_value()) return invoke(std::forward(f), *\exposid{val}); else return U(unexpect, error());} where \tcode{U} is \tcode{remove_cvref_t>}. +Equivalent to: \tcode{if (has_value()) return invoke(std::forward(f), *\exposid{val}); else return U(unexpect, error());} \pnum \remarks @@ -3574,11 +3586,11 @@ \pnum \mandates -\tcode{remove_cvref_t>} is a specialization of \tcode{expected} and its \tcode{error_type} is the same type as \tcode{E}. +\tcode{U} is a specialization of \tcode{expected} and \tcode{is_same_v} is \tcode{true}. \pnum \effects -Equivalent to: \tcode{if (has_value()) return invoke(std::forward(f), *\exposid{val}); else return U(unexpect, std::move(error()));} where \tcode{U} is \tcode{remove_cvref_t>}. +Equivalent to: \tcode{if (has_value()) return invoke(std::forward(f), *\exposid{val}); else return U(unexpect, std::move(error()));} \end{itemdescr} \indexlibrarymember{or_else}{expected}% @@ -3591,15 +3603,15 @@ \begin{itemdescr} \pnum -Let \tcode{G} be \tcode{remove_cvref_t>}. +Let \tcode{G} be \tcode{remove_cvref_t>}. \pnum \mandates -\tcode{remove_cvref_t>} is \tcode{expected} for some type \tcode{X}. +\tcode{G} is \tcode{expected} for some type \tcode{X}. \pnum \effects -Equivalent to: \tcode{if (has_value()) return G(*\exposid{val}); else return invoke(std::forward(f), error());} where \tcode{G} is \tcode{remove_cvref_t>}. +Equivalent to: \tcode{if (has_value()) return G(*\exposid{val}); else return invoke(std::forward(f), error());} \end{itemdescr} \indexlibrarymember{or_else}{expected}% @@ -3616,11 +3628,11 @@ \pnum \mandates -\tcode{remove_cvref_t>} is \tcode{expected} for some type \tcode{X}. +\tcode{G} is \tcode{expected} for some type \tcode{X}. \pnum \effects -Equivalent to: \tcode{if (has_value()) return G(*\exposid{val}); else return invoke(std::forward(f), std::move(error()));} where \tcode{G} is \tcode{remove_cvref_t>}. +Equivalent to: \tcode{if (has_value()) return G(*\exposid{val}); else return invoke(std::forward(f), std::move(error()));} \end{itemdescr} \indexlibrarymember{transform}{expected}% @@ -3632,13 +3644,16 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{U} be \tcode{remove_cv_t>}. + \pnum \constraints \tcode{is_constructible_v} is \tcode{true}. \pnum \effects -Equivalent to: \tcode{if (!has_value()) return U(unexpect, error()); else return expected(in_place, invoke(std::forward(f), *\exposid{val}));} where \tcode{U2} is \tcode{remove_cv_t>} and \tcode{U} is \tcode{expected}. +Equivalent to: \tcode{if (!has_value()) return expected(unexpect, error()); else return expected(in_place, invoke(std::forward(f), *\exposid{val}));} \end{itemdescr} \indexlibrarymember{transform}{expected}% @@ -3650,13 +3665,16 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{U} be \tcode{remove_cv_t>}. + \pnum \constraints \tcode{is_constructible_v} is \tcode{true}. \pnum \effects -Equivalent to: \tcode{if (!has_value()) return U(unexpect, std::move(error())); else return expected(in_place, invoke(std::forward(f), *\exposid{val}));} where \tcode{U2} is \tcode{remove_cv_t>} and \tcode{U} is \tcode{expected}. +Equivalent to: \tcode{if (!has_value()) return expected(unexpect, std::move(error())); else return expected(in_place, invoke(std::forward(f), *\exposid{val}));} \end{itemdescr} \indexlibrarymember{transform_error}{expected}% @@ -3669,7 +3687,7 @@ \begin{itemdescr} \pnum -Let \tcode{G} be \tcode{remove_cv_t>}. +Let \tcode{G} be \tcode{remove_cv_t>}. \pnum \mandates @@ -3682,7 +3700,7 @@ \pnum \effects -Equivalent to: \tcode{if (has_value()) return G(*\exposid{val}); else return expected(unexpect, invoke(std::forward(f), error()));} where \tcode{G2} is \tcode{remove_cv_t>} and \tcode{G} is \tcode{expected}. +Equivalent to: \tcode{if (has_value()) return expected(*\exposid{val}); else return expected(unexpect, invoke(std::forward(f), error()));} \end{itemdescr} \indexlibrarymember{transform_error}{expected}% @@ -3708,7 +3726,7 @@ \pnum \effects -Equivalent to: \tcode{if (has_value()) return G(*\exposid{val}); else return expected(unexpect, invoke(std::forward(f), std::move(error())));} where \tcode{G2} is \tcode{remove_cv_t>} and \tcode{G} is \tcode{expected}. +Equivalent to: \tcode{if (has_value()) return expected(*\exposid{val}); else return expected(unexpect, invoke(std::forward(f), std::move(error())));} \end{itemdescr} \rSec3[expected.ref.eq]{Equality operators} diff --git a/papers/wording/fragments/expected.expected.tex b/papers/wording/fragments/expected.expected.tex index c27a940f..b3947436 100644 --- a/papers/wording/fragments/expected.expected.tex +++ b/papers/wording/fragments/expected.expected.tex @@ -1036,7 +1036,7 @@ \begin{itemdescr} \pnum -Let \tcode{U} be \tcode{remove_cvref_t>}. +Let \tcode{U} be \tcode{remove_cvref_t>}. \pnum \constraints @@ -1044,11 +1044,11 @@ \pnum \mandates -\tcode{remove_cvref_t>} is a specialization of \tcode{expected} and its \tcode{error_type} is the same type as \tcode{E}. +\tcode{U} is a specialization of \tcode{expected} and \tcode{is_same_v} is \tcode{true}. \pnum \effects -Equivalent to: \tcode{if (has_value()) return invoke(std::forward(f), std::move(\exposid{val})); else return U(unexpect, std::move(error()));} where \tcode{U} is \tcode{remove_cvref_t>}. +Equivalent to: \tcode{if (has_value()) return invoke(std::forward(f), std::move(\exposid{val})); else return U(unexpect, std::move(error()));} \end{itemdescr} \indexlibrarymember{or_else}{expected}% @@ -1061,7 +1061,7 @@ \begin{itemdescr} \pnum -Let \tcode{G} be \tcode{remove_cvref_t>}. +Let \tcode{G} be \tcode{remove_cvref_t>}. \pnum \constraints @@ -1069,11 +1069,11 @@ \pnum \mandates -\tcode{remove_cvref_t>} is \tcode{expected} for some type \tcode{X}. +\tcode{G} is \tcode{expected} for some type \tcode{X}. \pnum \effects -Equivalent to: \tcode{if (has_value()) return G(in_place, \exposid{val}); else return invoke(std::forward(f), error());} where \tcode{G} is \tcode{remove_cvref_t>}. +Equivalent to: \tcode{if (has_value()) return G(in_place, \exposid{val}); else return invoke(std::forward(f), error());} \end{itemdescr} \indexlibrarymember{or_else}{expected}% @@ -1094,11 +1094,11 @@ \pnum \mandates -\tcode{remove_cvref_t>} is \tcode{expected} for some type \tcode{X}. +\tcode{G} is \tcode{expected} for some type \tcode{X}. \pnum \effects -Equivalent to: \tcode{if (has_value()) return G(in_place, std::move(\exposid{val})); else return invoke(std::forward(f), std::move(error()));} where \tcode{G} is \tcode{remove_cvref_t>}. +Equivalent to: \tcode{if (has_value()) return G(in_place, std::move(\exposid{val})); else return invoke(std::forward(f), std::move(error()));} \end{itemdescr} \indexlibrarymember{transform}{expected}% @@ -1110,13 +1110,16 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{U} be \tcode{remove_cv_t>}. + \pnum \constraints \tcode{is_constructible_v} is \tcode{true}. \pnum \effects -Equivalent to: \tcode{if (!has_value()) return U(unexpect, error()); else return expected(in_place, invoke(std::forward(f), \exposid{val}));} where \tcode{U2} is \tcode{remove_cv_t>} and \tcode{U} is \tcode{expected}. +Equivalent to: \tcode{if (!has_value()) return expected(unexpect, error()); else return expected(in_place, invoke(std::forward(f), \exposid{val}));} \end{itemdescr} \indexlibrarymember{transform}{expected}% @@ -1128,13 +1131,16 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{U} be \tcode{remove_cv_t>}. + \pnum \constraints \tcode{is_constructible_v} is \tcode{true}. \pnum \effects -Equivalent to: \tcode{if (!has_value()) return U(unexpect, std::move(error())); else return expected(in_place, invoke(std::forward(f), std::move(\exposid{val})));} where \tcode{U2} is \tcode{remove_cv_t>} and \tcode{U} is \tcode{expected}. +Equivalent to: \tcode{if (!has_value()) return expected(unexpect, std::move(error())); else return expected(in_place, invoke(std::forward(f), std::move(\exposid{val})));} \end{itemdescr} \indexlibrarymember{transform_error}{expected}% @@ -1147,7 +1153,7 @@ \begin{itemdescr} \pnum -Let \tcode{G} be \tcode{remove_cv_t>}. +Let \tcode{G} be \tcode{remove_cv_t>}. \pnum \constraints @@ -1164,7 +1170,7 @@ \pnum \effects -Equivalent to: \tcode{if (has_value()) return G(in_place, \exposid{val}); else return expected(unexpect, invoke(std::forward(f), error()));} where \tcode{G2} is \tcode{remove_cv_t>} and \tcode{G} is \tcode{expected}. +Equivalent to: \tcode{if (has_value()) return expected(in_place, \exposid{val}); else return expected(unexpect, invoke(std::forward(f), error()));} \end{itemdescr} \indexlibrarymember{transform_error}{expected}% @@ -1194,7 +1200,7 @@ \pnum \effects -Equivalent to: \tcode{if (has_value()) return G(in_place, std::move(\exposid{val})); else return expected(unexpect, invoke(std::forward(f), std::move(error())));} where \tcode{G2} is \tcode{remove_cv_t>} and \tcode{G} is \tcode{expected}. +Equivalent to: \tcode{if (has_value()) return expected(in_place, std::move(\exposid{val})); else return expected(unexpect, invoke(std::forward(f), std::move(error())));} \end{itemdescr} \rSec3[expected.object.eq]{Equality operators} diff --git a/papers/wording/fragments/expected.ref.tex b/papers/wording/fragments/expected.ref.tex index 56627b21..c6643acf 100644 --- a/papers/wording/fragments/expected.ref.tex +++ b/papers/wording/fragments/expected.ref.tex @@ -759,11 +759,11 @@ \pnum \mandates -\tcode{is_convertible_v>} and \tcode{is_convertible_v>} are \tcode{true}. +\tcode{is_convertible_v} and \tcode{is_convertible_v} are \tcode{true}. \pnum \returns -\tcode{has_value() ? static_cast>(*\exposid{val}) : static_cast>(std::forward(def))}. The result is an object, never a reference. +\tcode{has_value() ? static_cast(*\exposid{val}) : static_cast(std::forward(def))}. The result is an object, never a reference. \end{itemdescr} \indexlibrarymember{error_or}{expected}% @@ -818,11 +818,11 @@ \pnum \mandates -\tcode{remove_cvref_t>} is a specialization of \tcode{expected} and its \tcode{error_type} is the same type as \tcode{E}. +\tcode{U} is a specialization of \tcode{expected} and \tcode{is_same_v} is \tcode{true}. \pnum \effects -Equivalent to: \tcode{if (has_value()) return invoke(std::forward(f), *\exposid{val}); else return U(unexpect, error());} where \tcode{U} is \tcode{remove_cvref_t>}. +Equivalent to: \tcode{if (has_value()) return invoke(std::forward(f), *\exposid{val}); else return U(unexpect, error());} \pnum \remarks @@ -847,11 +847,11 @@ \pnum \mandates -\tcode{remove_cvref_t>} is a specialization of \tcode{expected} and its \tcode{error_type} is the same type as \tcode{E}. +\tcode{U} is a specialization of \tcode{expected} and \tcode{is_same_v} is \tcode{true}. \pnum \effects -Equivalent to: \tcode{if (has_value()) return invoke(std::forward(f), *\exposid{val}); else return U(unexpect, std::move(error()));} where \tcode{U} is \tcode{remove_cvref_t>}. +Equivalent to: \tcode{if (has_value()) return invoke(std::forward(f), *\exposid{val}); else return U(unexpect, std::move(error()));} \end{itemdescr} \indexlibrarymember{or_else}{expected}% @@ -864,15 +864,15 @@ \begin{itemdescr} \pnum -Let \tcode{G} be \tcode{remove_cvref_t>}. +Let \tcode{G} be \tcode{remove_cvref_t>}. \pnum \mandates -\tcode{remove_cvref_t>} is \tcode{expected} for some type \tcode{X}. +\tcode{G} is \tcode{expected} for some type \tcode{X}. \pnum \effects -Equivalent to: \tcode{if (has_value()) return G(*\exposid{val}); else return invoke(std::forward(f), error());} where \tcode{G} is \tcode{remove_cvref_t>}. +Equivalent to: \tcode{if (has_value()) return G(*\exposid{val}); else return invoke(std::forward(f), error());} \end{itemdescr} \indexlibrarymember{or_else}{expected}% @@ -889,11 +889,11 @@ \pnum \mandates -\tcode{remove_cvref_t>} is \tcode{expected} for some type \tcode{X}. +\tcode{G} is \tcode{expected} for some type \tcode{X}. \pnum \effects -Equivalent to: \tcode{if (has_value()) return G(*\exposid{val}); else return invoke(std::forward(f), std::move(error()));} where \tcode{G} is \tcode{remove_cvref_t>}. +Equivalent to: \tcode{if (has_value()) return G(*\exposid{val}); else return invoke(std::forward(f), std::move(error()));} \end{itemdescr} \indexlibrarymember{transform}{expected}% @@ -905,13 +905,16 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{U} be \tcode{remove_cv_t>}. + \pnum \constraints \tcode{is_constructible_v} is \tcode{true}. \pnum \effects -Equivalent to: \tcode{if (!has_value()) return U(unexpect, error()); else return expected(in_place, invoke(std::forward(f), *\exposid{val}));} where \tcode{U2} is \tcode{remove_cv_t>} and \tcode{U} is \tcode{expected}. +Equivalent to: \tcode{if (!has_value()) return expected(unexpect, error()); else return expected(in_place, invoke(std::forward(f), *\exposid{val}));} \end{itemdescr} \indexlibrarymember{transform}{expected}% @@ -923,13 +926,16 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{U} be \tcode{remove_cv_t>}. + \pnum \constraints \tcode{is_constructible_v} is \tcode{true}. \pnum \effects -Equivalent to: \tcode{if (!has_value()) return U(unexpect, std::move(error())); else return expected(in_place, invoke(std::forward(f), *\exposid{val}));} where \tcode{U2} is \tcode{remove_cv_t>} and \tcode{U} is \tcode{expected}. +Equivalent to: \tcode{if (!has_value()) return expected(unexpect, std::move(error())); else return expected(in_place, invoke(std::forward(f), *\exposid{val}));} \end{itemdescr} \indexlibrarymember{transform_error}{expected}% @@ -942,7 +948,7 @@ \begin{itemdescr} \pnum -Let \tcode{G} be \tcode{remove_cv_t>}. +Let \tcode{G} be \tcode{remove_cv_t>}. \pnum \mandates @@ -955,7 +961,7 @@ \pnum \effects -Equivalent to: \tcode{if (has_value()) return G(*\exposid{val}); else return expected(unexpect, invoke(std::forward(f), error()));} where \tcode{G2} is \tcode{remove_cv_t>} and \tcode{G} is \tcode{expected}. +Equivalent to: \tcode{if (has_value()) return expected(*\exposid{val}); else return expected(unexpect, invoke(std::forward(f), error()));} \end{itemdescr} \indexlibrarymember{transform_error}{expected}% @@ -981,7 +987,7 @@ \pnum \effects -Equivalent to: \tcode{if (has_value()) return G(*\exposid{val}); else return expected(unexpect, invoke(std::forward(f), std::move(error())));} where \tcode{G2} is \tcode{remove_cv_t>} and \tcode{G} is \tcode{expected}. +Equivalent to: \tcode{if (has_value()) return expected(*\exposid{val}); else return expected(unexpect, invoke(std::forward(f), std::move(error())));} \end{itemdescr} \rSec3[expected.ref.eq]{Equality operators} diff --git a/papers/wording/fragments/expected.void.tex b/papers/wording/fragments/expected.void.tex index 24e1154b..7d0145f0 100644 --- a/papers/wording/fragments/expected.void.tex +++ b/papers/wording/fragments/expected.void.tex @@ -800,11 +800,11 @@ \pnum \mandates -\tcode{remove_cvref_t>} is a specialization of \tcode{expected} and its \tcode{error_type} is the same type as \tcode{E}. +\tcode{U} is a specialization of \tcode{expected} and \tcode{is_same_v} is \tcode{true}. \pnum \effects -Equivalent to: \tcode{if (has_value()) return invoke(std::forward(f)); else return U(unexpect, error());} where \tcode{U} is \tcode{remove_cvref_t>}. +Equivalent to: \tcode{if (has_value()) return invoke(std::forward(f)); else return U(unexpect, error());} \end{itemdescr} \indexlibrarymember{and_then}{expected}% @@ -825,11 +825,11 @@ \pnum \mandates -\tcode{remove_cvref_t>} is a specialization of \tcode{expected} and its \tcode{error_type} is the same type as \tcode{E}. +\tcode{U} is a specialization of \tcode{expected} and \tcode{is_same_v} is \tcode{true}. \pnum \effects -Equivalent to: \tcode{if (has_value()) return invoke(std::forward(f)); else return U(unexpect, std::move(error()));} where \tcode{U} is \tcode{remove_cvref_t>}. +Equivalent to: \tcode{if (has_value()) return invoke(std::forward(f)); else return U(unexpect, std::move(error()));} \end{itemdescr} \indexlibrarymember{or_else}{expected}% @@ -842,15 +842,15 @@ \begin{itemdescr} \pnum -Let \tcode{G} be \tcode{remove_cvref_t>}. +Let \tcode{G} be \tcode{remove_cvref_t>}. \pnum \mandates -\tcode{remove_cvref_t>} is a specialization of \tcode{expected} and its \tcode{value_type} is the same type as \tcode{T}. +\tcode{G} is a specialization of \tcode{expected} and its \tcode{value_type} is the same type as \tcode{T}. \pnum \effects -Equivalent to: \tcode{if (has_value()) return G(); else return invoke(std::forward(f), error());} where \tcode{G} is \tcode{remove_cvref_t>}. +Equivalent to: \tcode{if (has_value()) return G(); else return invoke(std::forward(f), error());} \end{itemdescr} \indexlibrarymember{or_else}{expected}% @@ -867,11 +867,11 @@ \pnum \mandates -\tcode{remove_cvref_t>} is a specialization of \tcode{expected} and its \tcode{value_type} is the same type as \tcode{T}. +\tcode{G} is a specialization of \tcode{expected} and its \tcode{value_type} is the same type as \tcode{T}. \pnum \effects -Equivalent to: \tcode{if (has_value()) return G(); else return invoke(std::forward(f), std::move(error()));} where \tcode{G} is \tcode{remove_cvref_t>}. +Equivalent to: \tcode{if (has_value()) return G(); else return invoke(std::forward(f), std::move(error()));} \end{itemdescr} \indexlibrarymember{transform}{expected}% @@ -883,13 +883,16 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{U} be \tcode{remove_cv_t>}. + \pnum \constraints \tcode{is_constructible_v} is \tcode{true}. \pnum \mandates -\tcode{U} is a valid value type for \tcode{expected}, where \tcode{U} is \tcode{remove_cv_t>}. +\tcode{U} is a valid value type for \tcode{expected}. \pnum \effects @@ -905,13 +908,16 @@ \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{U} be \tcode{remove_cv_t>}. + \pnum \constraints \tcode{is_constructible_v} is \tcode{true}. \pnum \mandates -\tcode{U} is a valid value type for \tcode{expected}, where \tcode{U} is \tcode{remove_cv_t>}. +\tcode{U} is a valid value type for \tcode{expected}. \pnum \effects @@ -928,11 +934,11 @@ \begin{itemdescr} \pnum -Let \tcode{G} be \tcode{remove_cv_t>}. +Let \tcode{G} be \tcode{remove_cv_t>}. \pnum \mandates -\tcode{G} is a valid template argument for \tcode{unexpected} and the declaration \tcode{G g(invoke(std::forward(f), error()));} is well-formed, where \tcode{G} is \tcode{remove_cv_t>}. +\tcode{G} is a valid template argument for \tcode{unexpected} and the declaration \tcode{G g(invoke(std::forward(f), error()));} is well-formed. \pnum \returns @@ -953,7 +959,7 @@ \pnum \mandates -\tcode{G} is a valid template argument for \tcode{unexpected} and the declaration \tcode{G g(invoke(std::forward(f), std::move(error())));} is well-formed, where \tcode{G} is \tcode{remove_cv_t>}. +\tcode{G} is a valid template argument for \tcode{unexpected} and the declaration \tcode{G g(invoke(std::forward(f), std::move(error())));} is well-formed. \pnum \returns From dc94ab0a6d2538e7f5b18d80c3dd900342519e3f Mon Sep 17 00:00:00 2001 From: Steve Downey Date: Mon, 30 Nov 2026 00:47:24 -0500 Subject: [PATCH 08/24] Drop the draft's copy of the [expected.bad.void] synopsis from the header draft-text-copies: a copy goes when the generated synopsis of its class matches the draft's. [expected.bad.void] now has no marks against the draft at n5054, so the comment block is a third copy that nothing checks. The [expected.bad] copy stays; that synopsis still names the constructor's parameter. --- .../beman/expected/bad_expected_access.hpp | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/include/beman/expected/bad_expected_access.hpp b/include/beman/expected/bad_expected_access.hpp index 2152d249..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 { From 44063a0851bfd2c12dd10f2290e6a074fdc03ad3 Mon Sep 17 00:00:00 2001 From: Steve Downey Date: Mon, 30 Nov 2026 00:48:07 -0500 Subject: [PATCH 09/24] Record the rulings, the filed specgen issues and rvalue-error-binding macro-expansion-args and derived-let are decided as recommended, and derived-let is carried out. specgen#487 and #488 are filed and in the requests table. draft-text-copies logs the [expected.bad.void] copy gone. rvalue-error-binding opens the one place the draft's spelling of G names a different type from the code's, for a reference E. --- docs/plan/specgen-catchup.md | 66 ++++++++++++++++++++++++++++++++---- 1 file changed, 60 insertions(+), 6 deletions(-) diff --git a/docs/plan/specgen-catchup.md b/docs/plan/specgen-catchup.md index 93162dd2..1cbf52b4 100644 --- a/docs/plan/specgen-catchup.md +++ b/docs/plan/specgen-catchup.md @@ -29,7 +29,8 @@ 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. What else that unblocks is +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. --- @@ -921,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 @@ -1000,8 +1005,8 @@ spelling, of the kind specgen#282 settled for `= delete`. **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 @@ -1011,6 +1016,7 @@ 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. @@ -1018,6 +1024,7 @@ what the option is for. 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 @@ -1200,10 +1207,12 @@ headers by design, deferring to the primary template, and that belongs to **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.** OPEN -**Recommendation.** The alias is spelled as the draft binds it, with +**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. The authored *Mandates* name `U` in the +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 @@ -1211,6 +1220,7 @@ docblock's own. And the alias is read from one overload: for the `&` and `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 @@ -1218,6 +1228,39 @@ Using `U` in *Mandates* also lets `--validate` match the authored 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 four aliases 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.** OPEN +**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())`. +**Log.** +- 2026-11-30: opened, from [derived-let](#derived-let). ### specgen-pin @@ -1253,6 +1296,9 @@ the availability test in the makefile, and the pin are revisited then. 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 @@ -1300,6 +1346,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. From 3f2815e92a664faf124f592fb05157e139cc399b Mon Sep 17 00:00:00 2001 From: Steve Downey Date: Mon, 30 Nov 2026 01:37:14 -0500 Subject: [PATCH 10/24] Log the review of rvalue-error-binding, and correct the alias count The rvalue G aliases left alone are twelve, four in each class, not four. The review's findings go in the question's Log: the paper's own design section already makes move-the-wrapper-then-access a guarantee, the code follows it, and 26 places in the wording do not. --- docs/plan/specgen-catchup.md | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/docs/plan/specgen-catchup.md b/docs/plan/specgen-catchup.md index 1cbf52b4..3c5cf660 100644 --- a/docs/plan/specgen-catchup.md +++ b/docs/plan/specgen-catchup.md @@ -1237,7 +1237,8 @@ Using `U` in *Mandates* also lets `--validate` match the authored 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 four aliases keep + 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 @@ -1261,6 +1262,32 @@ 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())`. **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. ### specgen-pin From 412d0667b2040699a9d0aad0f58a78e3763a1309 Mon Sep 17 00:00:00 2001 From: Steve Downey Date: Mon, 30 Nov 2026 01:39:33 -0500 Subject: [PATCH 11/24] Take the decision numbers out of D4280's section titles The design sections were titled with serial numbers, (D1) to (D12), and two sentences referred to a decision by number. A reader of the paper has no list those numbers index. The titles now stand alone and the two sentences say what they mean without the number. The unmerged prose pass on expected-over-references-paper makes the same change to the titles; the wording here matches it. --- papers/D4280R0.tex | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/papers/D4280R0.tex b/papers/D4280R0.tex index e242cefb..3f819932 100644 --- a/papers/D4280R0.tex +++ b/papers/D4280R0.tex @@ -441,7 +441,7 @@ \chapter{Design choices and decisions} The implementation was built against a numbered decision log. The decisions that shape the interface are argued here, so LEWG can poll against the numbers. -\section{Rebind on assignment, never assign-through (D1)} +\section{Rebind on assignment, never assign-through} Assignment to an engaged \tcode{expected} rebinds the internal pointer. It does not assign through to the referent. @@ -459,7 +459,7 @@ \section{Rebind on assignment, never assign-through (D1)} \tcode{emplace} rebinds too --- it is the only thing it can do --- and \tcode{swap} exchanges the two pointers and leaves the referents alone. -\section{Shallow \tcode{const} (D2)} +\section{Shallow \tcode{const}} A \tcode{const expected} yields a non-\tcode{const} \tcode{T\&} from \tcode{operator*}. The binding is \tcode{const}; the referent is not. The model @@ -472,7 +472,7 @@ \section{Shallow \tcode{const} (D2)} promise --- a \tcode{T* const} does not either --- and the mistake is in reading \tcode{const} on a handle as \tcode{const} on the referent. -\section{Dangling constructors are deleted, with a diagnostic (D3)} +\section{Dangling constructors are deleted, with a diagnostic} Every constructor that would bind \tcode{T\&} (or \tcode{E\&}) to a temporary is deleted, guarded by \tcode{reference_constructs_from_temporary_v} @@ -493,7 +493,7 @@ \section{Dangling constructors are deleted, with a diagnostic (D3)} rejecting prvalues would therefore require information this interface cannot recover, so both are conservatively rejected. -\section{References in the error position, by relaxation not specialization (D4)} +\section{References in the error position, by relaxation not specialization} The error type is a template parameter, and errors are routinely owned elsewhere --- a diagnostics engine, an error registry, a long-lived context @@ -507,7 +507,7 @@ \section{References in the error position, by relaxation not specialization (D4) to express \tcode{expected} while \tcode{expected} works would be inconsistent, hostile, and strictly worse than disallowing both. -\section{\tcode{unexpected}, and the reference-only rule (D5)} +\section{\tcode{unexpected}, and the reference-only rule} To construct an \tcode{expected} with a reference error, \tcode{unexpected} has to be able to hold one, so \tcode{unexpected} is part of the proposal. It @@ -563,7 +563,7 @@ \section{\tcode{value\_type} is \tcode{T}, not \tcode{T\&}} \tcode{expected} for the reference specialization. No program that was valid before is rejected. -\section{\tcode{value\_or} returns by value; \tcode{error\_or} mirrors it (D6)} +\section{\tcode{value\_or} returns by value; \tcode{error\_or} mirrors it} \tcode{value_or} returns \tcode{T} by value, as \tcode{optional::value_or} does \cite{P2988R12}: a reference return would @@ -578,7 +578,7 @@ \section{\tcode{value\_or} returns by value; \tcode{error\_or} mirrors it (D6)} the reason instead of leaving the reader to infer it from ``no member named \tcode{value_or}.'' -\section{No default constructor, no in-place value, \tcode{emplace} rebinds (D7)} +\section{No default constructor, no in-place value, \tcode{emplace} rebinds} An engaged \tcode{expected} must hold a real reference; there is no null reference, so there is no default constructor. \tcode{expected(in_place, ...)} @@ -586,7 +586,7 @@ \section{No default constructor, no in-place value, \tcode{emplace} rebinds (D7) rebinds the pointer, which is the only thing it can do; nothing is being ``emplaced,'' but the name is kept for parallelism with the primary template. -\section{Monadic operations are uniform (D8)} +\section{Monadic operations are uniform} \tcode{and_then}, \tcode{transform}, \tcode{or_else}, and \tcode{transform_error} are provided on every specialization. On a reference @@ -597,7 +597,7 @@ \section{Monadic operations are uniform (D8)} kept for parity with the primary template even though, for a reference, they do the same work. -\section{Shallow conversions must not steal (D9)} +\section{Shallow conversions must not steal} Converting a reference-holding \tcode{expected} to a value-holding one copies the referent; it never moves out of it, even from an rvalue source. @@ -617,7 +617,7 @@ \section{Shallow conversions must not steal (D9)} the wrapper does not own, and steal from the caller's object. Because it is a guarantee and not merely an implementation habit, it belongs in the design. -\section{Deleted functions carry messages (D10)} +\section{Deleted functions carry messages} Every deleted operation says what is wrong and what to do instead. For example, the deleted default constructor explains that \tcode{T\&} cannot be null. @@ -626,9 +626,9 @@ \section{Deleted functions carry messages (D10)} message text. \section{The held \tcode{unexpected} is exposition-only; the observable - behavior is keyed on \tcode{E} (D11)} + behavior is keyed on \tcode{E}} -Storing the error as \tcode{unexpected} (D4) is a specification device, not a +Storing the error as \tcode{unexpected} is a specification device, not a representation mandate. It supplies the reference case --- \tcode{unexpected} holds a pointer --- without a new specialization, and that is its only purpose. In particular it must not reach an existing implementation and tell it to change @@ -660,7 +660,7 @@ \section{The held \tcode{unexpected} is exposition-only; the observable described, never what the program is allowed to observe. \section{\tcode{expected} is trivially copyable when \tcode{T} and - \tcode{E} are (D12)} + \tcode{E} are} A drive-by. \tcode{expected} is not trivially copyable today, because \tcode{expected}'s copy and move assignment are specified as non-trivial @@ -738,7 +738,7 @@ \chapter{Wording} shallow-\tcode{const} observers. Marked edits in place widen the error type of the primary \tcode{expected} and of \tcode{expected} to admit an lvalue reference, and add \tcode{unexpected} with the reference-only -construction rule of D5. The Mandates of the primary template's +construction rule above. The Mandates of the primary template's \tcode{or_else} is restated so that it names \tcode{expected} rather than comparing \tcode{value_type}, which no longer separates \tcode{expected} from \tcode{expected}. The marked edits From a7572c2a409b85bb780db89ea75a743e3e095673 Mon Sep 17 00:00:00 2001 From: Steve Downey Date: Mon, 30 Nov 2026 01:47:12 -0500 Subject: [PATCH 12/24] Move the holder, not the error, in the rvalue observers and monadic operations The wording said `std::move(error())` in 26 places: access, then move. For an object E that is the draft's text and means what it meant. For a reference E it marks as an rvalue an object that the expected does not own. Read as written, `error_or() &&` and `value() &&` would move out of the referent themselves, the rvalue `or_else` and `transform_error` would hand the callable an rvalue to it, and the rvalue `and_then` and `transform` would be constrained away or ill-formed. The code never did any of this: it moves the held unexpected and then asks it for the error. The docblocks now say what the code does, `std::move(unex).error()`, the form the paper's design already requires and that `error() &&` already used. `unex` is the exposition-only unexpected of all three classes, so the expression is E&& for an object E, as before, and E& for a reference E, for both `&&` and `const&&`. The twelve rvalue G aliases are spelled the same way, so the derived "Let G be ..." is exact for both overloads of its item, which `E&&` was not. The two assertions in `value() &&` follow, and no access-then-move is left in the code. No type changes. --- include/beman/expected/expected.hpp | 82 ++++++++++--------- papers/wording/expected.tex | 64 +++++++-------- .../wording/fragments/expected.expected.tex | 22 ++--- papers/wording/fragments/expected.ref.tex | 20 ++--- papers/wording/fragments/expected.void.tex | 22 ++--- 5 files changed, 106 insertions(+), 104 deletions(-) diff --git a/include/beman/expected/expected.hpp b/include/beman/expected/expected.hpp index 396af487..43fa33e7 100644 --- a/include/beman/expected/expected.hpp +++ b/include/beman/expected/expected.hpp @@ -1374,9 +1374,9 @@ constexpr T& expected::value() & { //! \freestanding-deleted //! \group obs-value-rval //! \mandates `is_copy_constructible_v` is `true` and -//! `is_constructible_v` is `true`. +//! `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&& { @@ -1384,7 +1384,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_) @@ -1400,7 +1401,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_) @@ -1496,7 +1498,7 @@ constexpr typename expected::error_value_type expected::error_or(G&& //! \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> && @@ -1531,13 +1533,13 @@ constexpr auto expected::and_then(F&& f) & { } //! \group monadic-and-then-rval -//! \constraints `is_constructible_v` is +//! \constraints `is_constructible_v` is //! `true`. //! \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()));` +//! std::move(unex).error());` template template requires std::is_constructible_v @@ -1606,12 +1608,12 @@ constexpr auto expected::or_else(F&& f) & { //! \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()));` +//! 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"); @@ -1639,7 +1641,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"); @@ -1681,10 +1683,10 @@ constexpr auto expected::transform(F&& f) & { //! \group monadic-transform-rval //! Let `U` be `remove_cv_t>`. -//! \constraints `is_constructible_v` is +//! \constraints `is_constructible_v` is //! `true`. //! \effects Equivalent to: `if (!has_value()) return expected(unexpect, std::move(error())); else return expected(in_place, +//! E>(unexpect, std::move(unex).error()); else return expected(in_place, //! invoke(std::forward(f), std::move(val)));` template template @@ -1788,12 +1790,12 @@ constexpr auto expected::transform_error(F&& f) & { //! `true`. //! \effects Equivalent to: `if (has_value()) return expected(in_place, std::move(val)); else return expected(unexpect, -//! invoke(std::forward(f), std::move(error())));` +//! invoke(std::forward(f), std::move(unex).error()));` template template requires std::is_constructible_v constexpr auto expected::transform_error(F&& f) && { - using G = std::remove_cv_t>; + using G = std::remove_cv_t>; static_assert(std::is_object_v, "transform_error: G must be an object type"); static_assert(!std::is_array_v, "transform_error: G must not be an array type"); static_assert(std::is_same_v>, "transform_error: G must not be cv-qualified"); @@ -1825,7 +1827,7 @@ template template requires std::is_constructible_v constexpr auto expected::transform_error(F&& f) const&& { - using G = std::remove_cv_t>; + using G = std::remove_cv_t>; static_assert(std::is_object_v, "transform_error: G must be an object type"); static_assert(!std::is_array_v, "transform_error: G must not be an array type"); static_assert(std::is_same_v>, "transform_error: G must not be cv-qualified"); @@ -2689,7 +2691,7 @@ constexpr void expected::value() const& { //! \freestanding-deleted //! \mandates `is_copy_constructible_v` is `true` and //! `is_move_constructible_v` 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 void expected::value() && { @@ -2760,7 +2762,7 @@ constexpr typename expected::error_value_type expected::error_ //! \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>> && @@ -2794,13 +2796,13 @@ constexpr auto expected::and_then(F&& f) & { } //! \group void-monadic-and-then-rval -//! \constraints `is_constructible_v` is +//! \constraints `is_constructible_v` is //! `true`. //! \mandates `U` is a specialization of `expected` and //! `is_same_v` is `true`. //! \effects Equivalent to: `if (has_value()) return //! invoke(std::forward(f)); else return U(unexpect, -//! std::move(error()));` +//! std::move(unex).error());` template template requires std::is_constructible_v @@ -2866,11 +2868,11 @@ constexpr auto expected::or_else(F&& f) & { //! \mandates `G` is a specialization of `expected` and its `value_type` is //! the same type as `T`. //! \effects Equivalent to: `if (has_value()) return G(); else return -//! invoke(std::forward(f), std::move(error()));` +//! invoke(std::forward(f), std::move(unex).error());` template template 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 with the same value_type"); @@ -2896,7 +2898,7 @@ constexpr auto expected::or_else(F&& f) const& { template template 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 with the same value_type"); @@ -2942,11 +2944,11 @@ constexpr auto expected::transform(F&& f) & { //! \group void-monadic-transform-rval //! Let `U` be `remove_cv_t>`. -//! \constraints `is_constructible_v` is +//! \constraints `is_constructible_v` is //! `true`. //! \mandates `U` is a valid value type for `expected`. //! \effects If `has_value()` is `false`, returns `expected(unexpect, -//! std::move(error()))`. Otherwise, if `is_void_v` is `false`, returns +//! std::move(unex).error())`. Otherwise, if `is_void_v` is `false`, returns //! an `expected` object whose `has_val` member is `true` and `val` //! member is direct-non-list-initialized with `invoke(std::forward(f))`. //! Otherwise, evaluates `invoke(std::forward(f))` and then returns @@ -3052,16 +3054,16 @@ constexpr auto expected::transform_error(F&& f) & { //! \group void-monadic-transform-error-rval //! \mandates `G` is a valid template argument for `unexpected` and the -//! declaration `G g(invoke(std::forward(f), std::move(error())));` is +//! declaration `G g(invoke(std::forward(f), std::move(unex).error()));` is //! well-formed. //! \returns If `has_value()` is `true`, `expected()`; otherwise, an //! `expected` object whose `has_val` member is `false` and `unex` //! member is direct-non-list-initialized with `invoke(std::forward(f), -//! std::move(error()))`. +//! std::move(unex).error())`. template template constexpr auto expected::transform_error(F&& f) && { - using G = std::remove_cv_t>; + using G = std::remove_cv_t>; static_assert(std::is_object_v, "transform_error: G must be an object type"); static_assert(!std::is_array_v, "transform_error: G must not be an array type"); static_assert(std::is_same_v>, "transform_error: G must not be cv-qualified"); @@ -3091,7 +3093,7 @@ constexpr auto expected::transform_error(F&& f) const& { template template constexpr auto expected::transform_error(F&& f) const&& { - using G = std::remove_cv_t>; + using G = std::remove_cv_t>; static_assert(std::is_object_v, "transform_error: G must be an object type"); static_assert(!std::is_array_v, "transform_error: G must not be an array type"); static_assert(std::is_same_v>, "transform_error: G must not be cv-qualified"); @@ -4044,7 +4046,7 @@ constexpr T& expected::value() const& { } //! \returns `*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 T& expected::value() && { @@ -4133,7 +4135,7 @@ constexpr typename expected::error_value_type expected::error_or(G } //! \returns `std::forward(def)` if `has_value()` is `true`, -//! `std::move(error())` otherwise. The result is an object, never a +//! `std::move(unex).error()` otherwise. The result is an object, never a //! reference. template template @@ -4174,13 +4176,13 @@ constexpr auto expected::and_then(F&& f) & { } //! \group ref-monadic-and-then-rval -//! \constraints `is_constructible_v` is +//! \constraints `is_constructible_v` is //! `true`. //! \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, -//! std::move(error()));` +//! std::move(unex).error());` template template requires std::is_constructible_v @@ -4244,11 +4246,11 @@ constexpr auto expected::or_else(F&& f) & { //! \group ref-monadic-or-else-rval //! \mandates `G` is `expected` for some type `X`. //! \effects Equivalent to: `if (has_value()) return G(*val); else return -//! invoke(std::forward(f), std::move(error()));` +//! invoke(std::forward(f), std::move(unex).error());` template template 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"); @@ -4274,7 +4276,7 @@ constexpr auto expected::or_else(F&& f) const& { template template 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"); @@ -4316,10 +4318,10 @@ constexpr auto expected::transform(F&& f) & { //! \group ref-monadic-transform-rval //! Let `U` be `remove_cv_t>`. -//! \constraints `is_constructible_v` is +//! \constraints `is_constructible_v` is //! `true`. //! \effects Equivalent to: `if (!has_value()) return expected(unexpect, std::move(error())); else return expected(in_place, +//! E>(unexpect, std::move(unex).error()); else return expected(in_place, //! invoke(std::forward(f), *val));` template template @@ -4419,11 +4421,11 @@ constexpr auto expected::transform_error(F&& f) & { //! \group ref-monadic-transform-error-rval //! \effects Equivalent to: `if (has_value()) return expected(*val); //! else return expected(unexpect, invoke(std::forward(f), -//! std::move(error())));` +//! std::move(unex).error()));` template template constexpr auto expected::transform_error(F&& f) && { - using G = std::remove_cv_t>; + using G = std::remove_cv_t>; static_assert(std::is_object_v, "transform_error: G must be an object type"); static_assert(!std::is_array_v, "transform_error: G must not be an array type"); static_assert(std::is_same_v>, "transform_error: G must not be cv-qualified"); @@ -4453,7 +4455,7 @@ constexpr auto expected::transform_error(F&& f) const& { template template constexpr auto expected::transform_error(F&& f) const&& { - using G = std::remove_cv_t>; + using G = std::remove_cv_t>; static_assert(std::is_object_v, "transform_error: G must be an object type"); static_assert(!std::is_array_v, "transform_error: G must not be an array type"); static_assert(std::is_same_v>, "transform_error: G must not be cv-qualified"); diff --git a/papers/wording/expected.tex b/papers/wording/expected.tex index 31252cec..ca1ba872 100644 --- a/papers/wording/expected.tex +++ b/papers/wording/expected.tex @@ -1360,7 +1360,7 @@ \begin{itemdescr} \pnum \mandates -\tcode{is_copy_constructible_v} is \tcode{true} and \tcode{is_constructible_v} is \tcode{true}. +\tcode{is_copy_constructible_v} is \tcode{true} and \tcode{is_constructible_v} is \tcode{true}. \pnum \returns @@ -1368,7 +1368,7 @@ \pnum \throws -\tcode{bad_expected_access(std::move(error()))} if \tcode{has_value()} is \tcode{false}. +\tcode{bad_expected_access(std::move(\exposid{unex}).error())} if \tcode{has_value()} is \tcode{false}. \end{itemdescr} \indexlibrarymember{error}{expected}% @@ -1472,7 +1472,7 @@ \pnum \returns -\tcode{std::forward(def)} if \tcode{has_value()} is \tcode{true}, \tcode{std::move(error())} otherwise. +\tcode{std::forward(def)} if \tcode{has_value()} is \tcode{true}, \tcode{std::move(\exposid{unex}).error()} otherwise. \end{itemdescr} \rSec3[expected.object.monadic]{Monadic operations} @@ -1516,7 +1516,7 @@ \pnum \constraints -\tcode{is_constructible_v} is \tcode{true}. +\tcode{is_constructible_v} is \tcode{true}. \pnum \mandates @@ -1524,7 +1524,7 @@ \pnum \effects -Equivalent to: \tcode{if (has_value()) return invoke(std::forward(f), std::move(\exposid{val})); else return U(unexpect, std::move(error()));} +Equivalent to: \tcode{if (has_value()) return invoke(std::forward(f), std::move(\exposid{val})); else return U(unexpect, std::move(\exposid{unex}).error());} \end{itemdescr} \indexlibrarymember{or_else}{expected}% @@ -1562,7 +1562,7 @@ \begin{itemdescr} \pnum -Let \tcode{G} be \tcode{remove_cvref_t>}. +Let \tcode{G} be \tcode{remove_cvref_t>}. \pnum \constraints @@ -1574,7 +1574,7 @@ \pnum \effects -Equivalent to: \tcode{if (has_value()) return G(in_place, std::move(\exposid{val})); else return invoke(std::forward(f), std::move(error()));} +Equivalent to: \tcode{if (has_value()) return G(in_place, std::move(\exposid{val})); else return invoke(std::forward(f), std::move(\exposid{unex}).error());} \end{itemdescr} \indexlibrarymember{transform}{expected}% @@ -1612,11 +1612,11 @@ \pnum \constraints -\tcode{is_constructible_v} is \tcode{true}. +\tcode{is_constructible_v} is \tcode{true}. \pnum \effects -Equivalent to: \tcode{if (!has_value()) return expected(unexpect, std::move(error())); else return expected(in_place, invoke(std::forward(f), std::move(\exposid{val})));} +Equivalent to: \tcode{if (!has_value()) return expected(unexpect, std::move(\exposid{unex}).error()); else return expected(in_place, invoke(std::forward(f), std::move(\exposid{val})));} \end{itemdescr} \indexlibrarymember{transform_error}{expected}% @@ -1659,7 +1659,7 @@ \begin{itemdescr} \pnum -Let \tcode{G} be \tcode{remove_cv_t>}. +Let \tcode{G} be \tcode{remove_cv_t>}. \pnum \constraints @@ -1676,7 +1676,7 @@ \pnum \effects -Equivalent to: \tcode{if (has_value()) return expected(in_place, std::move(\exposid{val})); else return expected(unexpect, invoke(std::forward(f), std::move(error())));} +Equivalent to: \tcode{if (has_value()) return expected(in_place, std::move(\exposid{val})); else return expected(unexpect, invoke(std::forward(f), std::move(\exposid{unex}).error()));} \end{itemdescr} \rSec3[expected.object.eq]{Equality operators} @@ -2425,7 +2425,7 @@ \pnum \throws -\tcode{bad_expected_access(std::move(error()))} if \tcode{has_value()} is \tcode{false}. +\tcode{bad_expected_access(std::move(\exposid{unex}).error())} if \tcode{has_value()} is \tcode{false}. \end{itemdescr} \indexlibrarymember{error}{expected}% @@ -2497,7 +2497,7 @@ \pnum \returns -\tcode{std::forward(def)} if \tcode{has_value()} is \tcode{true}, \tcode{std::move(error())} otherwise. +\tcode{std::forward(def)} if \tcode{has_value()} is \tcode{true}, \tcode{std::move(\exposid{unex}).error()} otherwise. \end{itemdescr} \indexlibrarymember{value_or}{expected}% @@ -2557,7 +2557,7 @@ \pnum \constraints -\tcode{is_constructible_v} is \tcode{true}. +\tcode{is_constructible_v} is \tcode{true}. \pnum \mandates @@ -2565,7 +2565,7 @@ \pnum \effects -Equivalent to: \tcode{if (has_value()) return invoke(std::forward(f)); else return U(unexpect, std::move(error()));} +Equivalent to: \tcode{if (has_value()) return invoke(std::forward(f)); else return U(unexpect, std::move(\exposid{unex}).error());} \end{itemdescr} \indexlibrarymember{or_else}{expected}% @@ -2599,7 +2599,7 @@ \begin{itemdescr} \pnum -Let \tcode{G} be \tcode{remove_cvref_t>}. +Let \tcode{G} be \tcode{remove_cvref_t>}. \pnum \mandates @@ -2607,7 +2607,7 @@ \pnum \effects -Equivalent to: \tcode{if (has_value()) return G(); else return invoke(std::forward(f), std::move(error()));} +Equivalent to: \tcode{if (has_value()) return G(); else return invoke(std::forward(f), std::move(\exposid{unex}).error());} \end{itemdescr} \indexlibrarymember{transform}{expected}% @@ -2649,7 +2649,7 @@ \pnum \constraints -\tcode{is_constructible_v} is \tcode{true}. +\tcode{is_constructible_v} is \tcode{true}. \pnum \mandates @@ -2657,7 +2657,7 @@ \pnum \effects -If \tcode{has_value()} is \tcode{false}, returns \tcode{expected(unexpect, std::move(error()))}. Otherwise, if \tcode{is_void_v} is \tcode{false}, returns an \tcode{expected} object whose \exposid{has_val} member is \tcode{true} and \tcode{val} member is direct-non-list-initialized with \tcode{invoke(std::forward(f))}. Otherwise, evaluates \tcode{invoke(std::forward(f))} and then returns \tcode{expected()}. +If \tcode{has_value()} is \tcode{false}, returns \tcode{expected(unexpect, std::move(\exposid{unex}).error())}. Otherwise, if \tcode{is_void_v} is \tcode{false}, returns an \tcode{expected} object whose \exposid{has_val} member is \tcode{true} and \tcode{val} member is direct-non-list-initialized with \tcode{invoke(std::forward(f))}. Otherwise, evaluates \tcode{invoke(std::forward(f))} and then returns \tcode{expected()}. \end{itemdescr} \indexlibrarymember{transform_error}{expected}% @@ -2691,15 +2691,15 @@ \begin{itemdescr} \pnum -Let \tcode{G} be \tcode{remove_cv_t>}. +Let \tcode{G} be \tcode{remove_cv_t>}. \pnum \mandates -\tcode{G} is a valid template argument for \tcode{unexpected} and the declaration \tcode{G g(invoke(std::forward(f), std::move(error())));} is well-formed. +\tcode{G} is a valid template argument for \tcode{unexpected} and the declaration \tcode{G g(invoke(std::forward(f), std::move(\exposid{unex}).error()));} is well-formed. \pnum \returns -If \tcode{has_value()} is \tcode{true}, \tcode{expected()}; otherwise, an \tcode{expected} object whose \exposid{has_val} member is \tcode{false} and \exposid{unex} member is direct-non-list-initialized with \tcode{invoke(std::forward(f), std::move(error()))}. +If \tcode{has_value()} is \tcode{true}, \tcode{expected()}; otherwise, an \tcode{expected} object whose \exposid{has_val} member is \tcode{false} and \exposid{unex} member is direct-non-list-initialized with \tcode{invoke(std::forward(f), std::move(\exposid{unex}).error())}. \end{itemdescr} \rSec3[expected.void.eq]{Equality operators} @@ -3447,7 +3447,7 @@ \pnum \throws -\tcode{bad_expected_access(std::move(error()))} if \tcode{has_value()} is \tcode{false}. +\tcode{bad_expected_access(std::move(\exposid{unex}).error())} if \tcode{has_value()} is \tcode{false}. \end{itemdescr} \indexlibrarymember{error}{expected}% @@ -3534,7 +3534,7 @@ \pnum \returns -\tcode{std::forward(def)} if \tcode{has_value()} is \tcode{true}, \tcode{std::move(error())} otherwise. The result is an object, never a reference. +\tcode{std::forward(def)} if \tcode{has_value()} is \tcode{true}, \tcode{std::move(\exposid{unex}).error()} otherwise. The result is an object, never a reference. \end{itemdescr} \rSec3[expected.ref.monadic]{Monadic operations} @@ -3582,7 +3582,7 @@ \pnum \constraints -\tcode{is_constructible_v} is \tcode{true}. +\tcode{is_constructible_v} is \tcode{true}. \pnum \mandates @@ -3590,7 +3590,7 @@ \pnum \effects -Equivalent to: \tcode{if (has_value()) return invoke(std::forward(f), *\exposid{val}); else return U(unexpect, std::move(error()));} +Equivalent to: \tcode{if (has_value()) return invoke(std::forward(f), *\exposid{val}); else return U(unexpect, std::move(\exposid{unex}).error());} \end{itemdescr} \indexlibrarymember{or_else}{expected}% @@ -3624,7 +3624,7 @@ \begin{itemdescr} \pnum -Let \tcode{G} be \tcode{remove_cvref_t>}. +Let \tcode{G} be \tcode{remove_cvref_t>}. \pnum \mandates @@ -3632,7 +3632,7 @@ \pnum \effects -Equivalent to: \tcode{if (has_value()) return G(*\exposid{val}); else return invoke(std::forward(f), std::move(error()));} +Equivalent to: \tcode{if (has_value()) return G(*\exposid{val}); else return invoke(std::forward(f), std::move(\exposid{unex}).error());} \end{itemdescr} \indexlibrarymember{transform}{expected}% @@ -3670,11 +3670,11 @@ \pnum \constraints -\tcode{is_constructible_v} is \tcode{true}. +\tcode{is_constructible_v} is \tcode{true}. \pnum \effects -Equivalent to: \tcode{if (!has_value()) return expected(unexpect, std::move(error())); else return expected(in_place, invoke(std::forward(f), *\exposid{val}));} +Equivalent to: \tcode{if (!has_value()) return expected(unexpect, std::move(\exposid{unex}).error()); else return expected(in_place, invoke(std::forward(f), *\exposid{val}));} \end{itemdescr} \indexlibrarymember{transform_error}{expected}% @@ -3713,7 +3713,7 @@ \begin{itemdescr} \pnum -Let \tcode{G} be \tcode{remove_cv_t>}. +Let \tcode{G} be \tcode{remove_cv_t>}. \pnum \mandates @@ -3726,7 +3726,7 @@ \pnum \effects -Equivalent to: \tcode{if (has_value()) return expected(*\exposid{val}); else return expected(unexpect, invoke(std::forward(f), std::move(error())));} +Equivalent to: \tcode{if (has_value()) return expected(*\exposid{val}); else return expected(unexpect, invoke(std::forward(f), std::move(\exposid{unex}).error()));} \end{itemdescr} \rSec3[expected.ref.eq]{Equality operators} diff --git a/papers/wording/fragments/expected.expected.tex b/papers/wording/fragments/expected.expected.tex index b3947436..0b1f225b 100644 --- a/papers/wording/fragments/expected.expected.tex +++ b/papers/wording/fragments/expected.expected.tex @@ -884,7 +884,7 @@ \begin{itemdescr} \pnum \mandates -\tcode{is_copy_constructible_v} is \tcode{true} and \tcode{is_constructible_v} is \tcode{true}. +\tcode{is_copy_constructible_v} is \tcode{true} and \tcode{is_constructible_v} is \tcode{true}. \pnum \returns @@ -892,7 +892,7 @@ \pnum \throws -\tcode{bad_expected_access(std::move(error()))} if \tcode{has_value()} is \tcode{false}. +\tcode{bad_expected_access(std::move(\exposid{unex}).error())} if \tcode{has_value()} is \tcode{false}. \end{itemdescr} \indexlibrarymember{error}{expected}% @@ -996,7 +996,7 @@ \pnum \returns -\tcode{std::forward(def)} if \tcode{has_value()} is \tcode{true}, \tcode{std::move(error())} otherwise. +\tcode{std::forward(def)} if \tcode{has_value()} is \tcode{true}, \tcode{std::move(\exposid{unex}).error()} otherwise. \end{itemdescr} \rSec3[expected.object.monadic]{Monadic operations} @@ -1040,7 +1040,7 @@ \pnum \constraints -\tcode{is_constructible_v} is \tcode{true}. +\tcode{is_constructible_v} is \tcode{true}. \pnum \mandates @@ -1048,7 +1048,7 @@ \pnum \effects -Equivalent to: \tcode{if (has_value()) return invoke(std::forward(f), std::move(\exposid{val})); else return U(unexpect, std::move(error()));} +Equivalent to: \tcode{if (has_value()) return invoke(std::forward(f), std::move(\exposid{val})); else return U(unexpect, std::move(\exposid{unex}).error());} \end{itemdescr} \indexlibrarymember{or_else}{expected}% @@ -1086,7 +1086,7 @@ \begin{itemdescr} \pnum -Let \tcode{G} be \tcode{remove_cvref_t>}. +Let \tcode{G} be \tcode{remove_cvref_t>}. \pnum \constraints @@ -1098,7 +1098,7 @@ \pnum \effects -Equivalent to: \tcode{if (has_value()) return G(in_place, std::move(\exposid{val})); else return invoke(std::forward(f), std::move(error()));} +Equivalent to: \tcode{if (has_value()) return G(in_place, std::move(\exposid{val})); else return invoke(std::forward(f), std::move(\exposid{unex}).error());} \end{itemdescr} \indexlibrarymember{transform}{expected}% @@ -1136,11 +1136,11 @@ \pnum \constraints -\tcode{is_constructible_v} is \tcode{true}. +\tcode{is_constructible_v} is \tcode{true}. \pnum \effects -Equivalent to: \tcode{if (!has_value()) return expected(unexpect, std::move(error())); else return expected(in_place, invoke(std::forward(f), std::move(\exposid{val})));} +Equivalent to: \tcode{if (!has_value()) return expected(unexpect, std::move(\exposid{unex}).error()); else return expected(in_place, invoke(std::forward(f), std::move(\exposid{val})));} \end{itemdescr} \indexlibrarymember{transform_error}{expected}% @@ -1183,7 +1183,7 @@ \begin{itemdescr} \pnum -Let \tcode{G} be \tcode{remove_cv_t>}. +Let \tcode{G} be \tcode{remove_cv_t>}. \pnum \constraints @@ -1200,7 +1200,7 @@ \pnum \effects -Equivalent to: \tcode{if (has_value()) return expected(in_place, std::move(\exposid{val})); else return expected(unexpect, invoke(std::forward(f), std::move(error())));} +Equivalent to: \tcode{if (has_value()) return expected(in_place, std::move(\exposid{val})); else return expected(unexpect, invoke(std::forward(f), std::move(\exposid{unex}).error()));} \end{itemdescr} \rSec3[expected.object.eq]{Equality operators} diff --git a/papers/wording/fragments/expected.ref.tex b/papers/wording/fragments/expected.ref.tex index c6643acf..1715654f 100644 --- a/papers/wording/fragments/expected.ref.tex +++ b/papers/wording/fragments/expected.ref.tex @@ -708,7 +708,7 @@ \pnum \throws -\tcode{bad_expected_access(std::move(error()))} if \tcode{has_value()} is \tcode{false}. +\tcode{bad_expected_access(std::move(\exposid{unex}).error())} if \tcode{has_value()} is \tcode{false}. \end{itemdescr} \indexlibrarymember{error}{expected}% @@ -795,7 +795,7 @@ \pnum \returns -\tcode{std::forward(def)} if \tcode{has_value()} is \tcode{true}, \tcode{std::move(error())} otherwise. The result is an object, never a reference. +\tcode{std::forward(def)} if \tcode{has_value()} is \tcode{true}, \tcode{std::move(\exposid{unex}).error()} otherwise. The result is an object, never a reference. \end{itemdescr} \rSec3[expected.ref.monadic]{Monadic operations} @@ -843,7 +843,7 @@ \pnum \constraints -\tcode{is_constructible_v} is \tcode{true}. +\tcode{is_constructible_v} is \tcode{true}. \pnum \mandates @@ -851,7 +851,7 @@ \pnum \effects -Equivalent to: \tcode{if (has_value()) return invoke(std::forward(f), *\exposid{val}); else return U(unexpect, std::move(error()));} +Equivalent to: \tcode{if (has_value()) return invoke(std::forward(f), *\exposid{val}); else return U(unexpect, std::move(\exposid{unex}).error());} \end{itemdescr} \indexlibrarymember{or_else}{expected}% @@ -885,7 +885,7 @@ \begin{itemdescr} \pnum -Let \tcode{G} be \tcode{remove_cvref_t>}. +Let \tcode{G} be \tcode{remove_cvref_t>}. \pnum \mandates @@ -893,7 +893,7 @@ \pnum \effects -Equivalent to: \tcode{if (has_value()) return G(*\exposid{val}); else return invoke(std::forward(f), std::move(error()));} +Equivalent to: \tcode{if (has_value()) return G(*\exposid{val}); else return invoke(std::forward(f), std::move(\exposid{unex}).error());} \end{itemdescr} \indexlibrarymember{transform}{expected}% @@ -931,11 +931,11 @@ \pnum \constraints -\tcode{is_constructible_v} is \tcode{true}. +\tcode{is_constructible_v} is \tcode{true}. \pnum \effects -Equivalent to: \tcode{if (!has_value()) return expected(unexpect, std::move(error())); else return expected(in_place, invoke(std::forward(f), *\exposid{val}));} +Equivalent to: \tcode{if (!has_value()) return expected(unexpect, std::move(\exposid{unex}).error()); else return expected(in_place, invoke(std::forward(f), *\exposid{val}));} \end{itemdescr} \indexlibrarymember{transform_error}{expected}% @@ -974,7 +974,7 @@ \begin{itemdescr} \pnum -Let \tcode{G} be \tcode{remove_cv_t>}. +Let \tcode{G} be \tcode{remove_cv_t>}. \pnum \mandates @@ -987,7 +987,7 @@ \pnum \effects -Equivalent to: \tcode{if (has_value()) return expected(*\exposid{val}); else return expected(unexpect, invoke(std::forward(f), std::move(error())));} +Equivalent to: \tcode{if (has_value()) return expected(*\exposid{val}); else return expected(unexpect, invoke(std::forward(f), std::move(\exposid{unex}).error()));} \end{itemdescr} \rSec3[expected.ref.eq]{Equality operators} diff --git a/papers/wording/fragments/expected.void.tex b/papers/wording/fragments/expected.void.tex index 7d0145f0..be6a813e 100644 --- a/papers/wording/fragments/expected.void.tex +++ b/papers/wording/fragments/expected.void.tex @@ -689,7 +689,7 @@ \pnum \throws -\tcode{bad_expected_access(std::move(error()))} if \tcode{has_value()} is \tcode{false}. +\tcode{bad_expected_access(std::move(\exposid{unex}).error())} if \tcode{has_value()} is \tcode{false}. \end{itemdescr} \indexlibrarymember{error}{expected}% @@ -761,7 +761,7 @@ \pnum \returns -\tcode{std::forward(def)} if \tcode{has_value()} is \tcode{true}, \tcode{std::move(error())} otherwise. +\tcode{std::forward(def)} if \tcode{has_value()} is \tcode{true}, \tcode{std::move(\exposid{unex}).error()} otherwise. \end{itemdescr} \indexlibrarymember{value_or}{expected}% @@ -821,7 +821,7 @@ \pnum \constraints -\tcode{is_constructible_v} is \tcode{true}. +\tcode{is_constructible_v} is \tcode{true}. \pnum \mandates @@ -829,7 +829,7 @@ \pnum \effects -Equivalent to: \tcode{if (has_value()) return invoke(std::forward(f)); else return U(unexpect, std::move(error()));} +Equivalent to: \tcode{if (has_value()) return invoke(std::forward(f)); else return U(unexpect, std::move(\exposid{unex}).error());} \end{itemdescr} \indexlibrarymember{or_else}{expected}% @@ -863,7 +863,7 @@ \begin{itemdescr} \pnum -Let \tcode{G} be \tcode{remove_cvref_t>}. +Let \tcode{G} be \tcode{remove_cvref_t>}. \pnum \mandates @@ -871,7 +871,7 @@ \pnum \effects -Equivalent to: \tcode{if (has_value()) return G(); else return invoke(std::forward(f), std::move(error()));} +Equivalent to: \tcode{if (has_value()) return G(); else return invoke(std::forward(f), std::move(\exposid{unex}).error());} \end{itemdescr} \indexlibrarymember{transform}{expected}% @@ -913,7 +913,7 @@ \pnum \constraints -\tcode{is_constructible_v} is \tcode{true}. +\tcode{is_constructible_v} is \tcode{true}. \pnum \mandates @@ -921,7 +921,7 @@ \pnum \effects -If \tcode{has_value()} is \tcode{false}, returns \tcode{expected(unexpect, std::move(error()))}. Otherwise, if \tcode{is_void_v} is \tcode{false}, returns an \tcode{expected} object whose \exposid{has_val} member is \tcode{true} and \tcode{val} member is direct-non-list-initialized with \tcode{invoke(std::forward(f))}. Otherwise, evaluates \tcode{invoke(std::forward(f))} and then returns \tcode{expected()}. +If \tcode{has_value()} is \tcode{false}, returns \tcode{expected(unexpect, std::move(\exposid{unex}).error())}. Otherwise, if \tcode{is_void_v} is \tcode{false}, returns an \tcode{expected} object whose \exposid{has_val} member is \tcode{true} and \tcode{val} member is direct-non-list-initialized with \tcode{invoke(std::forward(f))}. Otherwise, evaluates \tcode{invoke(std::forward(f))} and then returns \tcode{expected()}. \end{itemdescr} \indexlibrarymember{transform_error}{expected}% @@ -955,15 +955,15 @@ \begin{itemdescr} \pnum -Let \tcode{G} be \tcode{remove_cv_t>}. +Let \tcode{G} be \tcode{remove_cv_t>}. \pnum \mandates -\tcode{G} is a valid template argument for \tcode{unexpected} and the declaration \tcode{G g(invoke(std::forward(f), std::move(error())));} is well-formed. +\tcode{G} is a valid template argument for \tcode{unexpected} and the declaration \tcode{G g(invoke(std::forward(f), std::move(\exposid{unex}).error()));} is well-formed. \pnum \returns -If \tcode{has_value()} is \tcode{true}, \tcode{expected()}; otherwise, an \tcode{expected} object whose \exposid{has_val} member is \tcode{false} and \exposid{unex} member is direct-non-list-initialized with \tcode{invoke(std::forward(f), std::move(error()))}. +If \tcode{has_value()} is \tcode{true}, \tcode{expected()}; otherwise, an \tcode{expected} object whose \exposid{has_val} member is \tcode{false} and \exposid{unex} member is direct-non-list-initialized with \tcode{invoke(std::forward(f), std::move(\exposid{unex}).error())}. \end{itemdescr} \rSec3[expected.void.eq]{Equality operators} From 00bcb8340c69439616f709e266c0a02154b8fae8 Mon Sep 17 00:00:00 2001 From: Steve Downey Date: Mon, 30 Nov 2026 01:47:12 -0500 Subject: [PATCH 13/24] Test that the rvalue observers and monadic operations do not steal a referenced error The guarantee was tested for the conversions only. These cover `error_or() &&` and `value() &&`, where the library itself initializes an object from the error, the rvalue `or_else` and `transform_error`, which must pass a referenced error to the callable as an lvalue, and the rvalue `and_then` and `transform`, which must rebind it. Each kind is paired with a case showing that an owned error is still moved. --- .../expected_review_corrections.test.cpp | 141 ++++++++++++++++++ 1 file changed, 141 insertions(+) diff --git a/tests/beman/expected/expected_review_corrections.test.cpp b/tests/beman/expected/expected_review_corrections.test.cpp index 8c55b343..09be30d4 100644 --- a/tests/beman/expected/expected_review_corrections.test.cpp +++ b/tests/beman/expected/expected_review_corrections.test.cpp @@ -382,3 +382,144 @@ TEST_CASE("converting from an rvalue value expected still moves", "[convert][mov REQUIRE(b.error() == "baz"); } } + +// ============================================================================= +// The same guarantee for the rvalue observers and monadic operations: an rvalue +// expected with a reference error moves the holder, std::move(unex).error(), and +// never the referent, which it does not own. Each case is paired with the +// value-E behavior, where the error is owned and is moved. +// ============================================================================= + +TEST_CASE("rvalue error_or does not steal a referenced error", "[ref_e][observers][shallow]") { + SECTION("expected") { + std::string s = "bar"; + expected e{unexpect, s}; + std::string got = std::move(e).error_or(std::string("x")); + REQUIRE(s == "bar"); // copied, not moved + REQUIRE(got == "bar"); + } + SECTION("expected") { + std::string s = "bar"; + expected e{unexpect, s}; + std::string got = std::move(e).error_or(std::string("x")); + REQUIRE(s == "bar"); + REQUIRE(got == "bar"); + } + SECTION("expected") { + std::string s = "bar"; + expected e{unexpect, s}; + std::string got = std::move(e).error_or(std::string("x")); + REQUIRE(s == "bar"); + REQUIRE(got == "bar"); + } + SECTION("an owned error is still moved") { + expected e{unexpect, "baz"}; + std::string got = std::move(e).error_or(std::string("x")); + REQUIRE(e.error().empty()); + REQUIRE(got == "baz"); + } +} + +TEST_CASE("rvalue value() does not steal a referenced error into the exception", "[ref_e][observers][shallow]") { + SECTION("expected") { + std::string s = "bar"; + expected e{unexpect, s}; + try { + (void)std::move(e).value(); + FAIL("value() must throw"); + } catch (const bad_expected_access& ex) { + REQUIRE(ex.error() == "bar"); + } + REQUIRE(s == "bar"); + } + SECTION("expected") { + std::string s = "bar"; + expected e{unexpect, s}; + try { + std::move(e).value(); + FAIL("value() must throw"); + } catch (const bad_expected_access& ex) { + REQUIRE(ex.error() == "bar"); + } + REQUIRE(s == "bar"); + } +} + +TEST_CASE("rvalue or_else and transform_error pass a referenced error as an lvalue", "[ref_e][monadic][shallow]") { + SECTION("or_else, expected") { + std::string s = "bar"; + expected e{unexpect, s}; + auto r = std::move(e).or_else([](auto&& x) -> expected { + static_assert(std::is_same_v); + return expected(unexpect, x); + }); + REQUIRE(s == "bar"); + REQUIRE(&r.error() == &s); + } + SECTION("or_else, const rvalue") { + std::string s = "bar"; + const expected e{unexpect, s}; + auto r = std::move(e).or_else([](auto&& x) -> expected { + static_assert(std::is_same_v); + return expected(unexpect, x); + }); + REQUIRE(s == "bar"); + REQUIRE(&r.error() == &s); + } + SECTION("or_else, expected") { + std::string s = "bar"; + expected e{unexpect, s}; + auto r = std::move(e).or_else([](auto&& x) -> expected { + static_assert(std::is_same_v); + return expected(unexpect, x); + }); + REQUIRE(s == "bar"); + REQUIRE(&r.error() == &s); + } + SECTION("transform_error, a callable that would move from an rvalue") { + std::string s = "bar"; + expected e{unexpect, s}; + auto r = std::move(e).transform_error([](auto&& x) { + static_assert(std::is_same_v); + return std::string(std::forward(x)); + }); + REQUIRE(s == "bar"); + REQUIRE(r.error() == "bar"); + } + SECTION("transform_error, expected") { + std::string s = "bar"; + expected e{unexpect, s}; + auto r = std::move(e).transform_error([](auto&& x) { + static_assert(std::is_same_v); + return std::string(std::forward(x)); + }); + REQUIRE(s == "bar"); + REQUIRE(r.error() == "bar"); + } + SECTION("an owned error is still passed as an rvalue") { + expected e{unexpect, "baz"}; + auto r = std::move(e).transform_error([](auto&& x) { + static_assert(std::is_same_v); + return std::string(std::forward(x)); + }); + REQUIRE(e.error().empty()); + REQUIRE(r.error() == "baz"); + } +} + +TEST_CASE("rvalue and_then and transform rebind a referenced error", "[ref_e][monadic][shallow]") { + SECTION("and_then") { + std::string s = "bar"; + expected e{unexpect, s}; + auto r = std::move(e).and_then([](int&&) { return expected(1L); }); + REQUIRE(s == "bar"); + REQUIRE(&r.error() == &s); + } + SECTION("transform") { + std::string s = "bar"; + expected e{unexpect, s}; + auto r = std::move(e).transform([](int&&) { return 1L; }); + REQUIRE(s == "bar"); + REQUIRE(&r.error() == &s); + } +} From de573858b65e36100f461c53c649b362e7603079 Mon Sep 17 00:00:00 2001 From: Steve Downey Date: Mon, 30 Nov 2026 01:47:47 -0500 Subject: [PATCH 14/24] Mark the rvalue error accesses in the paper's wording as std::move(unex).error() The paper's design makes move-the-holder-then-access a guarantee, and its wording for the rvalue observers and monadic operations still carried the draft's `std::move(error())`, which for a reference E moves the referent. 22 places in [expected.object] and [expected.void] are marked as changed to `std::move(unex).error()`, the expression `error() &&` already returns; the one in [expected.ref] is inside the added clause and is replaced without a mark. This is the text the headers now generate. --- papers/expected-new.tex | 46 ++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/papers/expected-new.tex b/papers/expected-new.tex index 4838e3c7..0f171075 100644 --- a/papers/expected-new.tex +++ b/papers/expected-new.tex @@ -1535,7 +1535,7 @@ \pnum \throws -\tcode{bad_expected_access(std::move(error()))} +\tcode{bad_expected_access(\removed{std::move(error())}\added{std::move(\exposid{unex}).error()})} if \tcode{has_value()} is \tcode{false}. \end{itemdescr} @@ -1640,7 +1640,7 @@ \pnum \returns \tcode{std::forward(e)} if \tcode{has_value()} is \tcode{true}, -\tcode{std::move(error())} otherwise. +\tcode{\removed{std::move(error())}\added{std::move(\exposid{unex}).error()}} otherwise. \end{itemdescr} \rSec3[expected.object.monadic]{Monadic operations} @@ -1688,7 +1688,7 @@ \pnum \constraints -\tcode{is_constructible_v} is \tcode{true}. +\tcode{is_constructible_v} is \tcode{true}. \pnum \mandates @@ -1702,7 +1702,7 @@ if (has_value()) return invoke(std::forward(f), std::move(@\exposid{val}@)); else - return U(unexpect, std::move(error())); + return U(unexpect, @\removed{std::move(error())}\added{std::move(\exposid{unex}).error()}@); \end{codeblock} \end{itemdescr} @@ -1746,7 +1746,7 @@ \begin{itemdescr} \pnum Let \tcode{G} be -\tcode{remove_cvref_t>}. +\tcode{remove_cvref_t>}. \pnum \constraints @@ -1765,7 +1765,7 @@ if (has_value()) return G(in_place, std::move(@\exposid{val}@)); else - return invoke(std::forward(f), std::move(error())); + return invoke(std::forward(f), @\removed{std::move(error())}\added{std::move(\exposid{unex}).error()}@); \end{codeblock} \end{itemdescr} @@ -1824,7 +1824,7 @@ \pnum \constraints -\tcode{is_constructible_v} is \tcode{true}. +\tcode{is_constructible_v} is \tcode{true}. \pnum \mandates @@ -1840,7 +1840,7 @@ \begin{itemize} \item If \tcode{has_value()} is \tcode{false}, returns -\tcode{expected(unexpect, std::move(error()))}. +\tcode{expected(unexpect, \removed{std::move(error())}\added{std::move(\exposid{unex}).error()})}. \item Otherwise, if \tcode{is_void_v} is \tcode{false}, returns an \tcode{expected} object whose \exposid{has_val} member is \tcode{true} @@ -1892,7 +1892,7 @@ \begin{itemdescr} \pnum Let \tcode{G} be -\tcode{remove_cv_t>}. +\tcode{remove_cv_t>}. \pnum \constraints @@ -1903,7 +1903,7 @@ \tcode{G} is a valid template argument for \tcode{unexpected}\iref{expected.un.general} and the declaration \begin{codeblock} -G g(invoke(std::forward(f), std::move(error()))); +G g(invoke(std::forward(f), @\removed{std::move(error())}\added{std::move(\exposid{unex}).error()}@)); \end{codeblock} is well-formed. @@ -1913,7 +1913,7 @@ \tcode{expected(in_place, std::move(\exposid{val}))}; otherwise, an \tcode{expected} object whose \exposid{has_val} member is \tcode{false} and \exposid{unex} member is direct-non-list-initialized with -\tcode{invoke(std::forward(f), std::move(error()))}. +\tcode{invoke(std::forward(f), \removed{std::move(error())}\added{std::move(\exposid{unex}).error()})}. \end{itemdescr} \rSec3[expected.object.eq]{Equality operators} @@ -2614,7 +2614,7 @@ \pnum \throws -\tcode{bad_expected_access(std::move(error()))} +\tcode{bad_expected_access(\removed{std::move(error())}\added{std::move(\exposid{unex}).error()})} if \tcode{has_value()} is \tcode{false}. \end{itemdescr} @@ -2687,7 +2687,7 @@ \pnum \returns \tcode{std::forward(e)} if \tcode{has_value()} is \tcode{true}, -\tcode{std::move(error())} otherwise. +\tcode{\removed{std::move(error())}\added{std::move(\exposid{unex}).error()}} otherwise. \end{itemdescr} \rSec3[expected.void.monadic]{Monadic operations} @@ -2734,7 +2734,7 @@ \pnum \constraints -\tcode{is_constructible_v} is \tcode{true}. +\tcode{is_constructible_v} is \tcode{true}. \pnum \mandates @@ -2748,7 +2748,7 @@ if (has_value()) return invoke(std::forward(f)); else - return U(unexpect, std::move(error())); + return U(unexpect, @\removed{std::move(error())}\added{std::move(\exposid{unex}).error()}@); \end{codeblock} \end{itemdescr} @@ -2787,7 +2787,7 @@ \begin{itemdescr} \pnum Let \tcode{G} be -\tcode{remove_cvref_t>}. +\tcode{remove_cvref_t>}. \pnum \mandates @@ -2801,7 +2801,7 @@ if (has_value()) return G(); else - return invoke(std::forward(f), std::move(error())); + return invoke(std::forward(f), @\removed{std::move(error())}\added{std::move(\exposid{unex}).error()}@); \end{codeblock} \end{itemdescr} @@ -2857,7 +2857,7 @@ \pnum \constraints -\tcode{is_constructible_v} is \tcode{true}. +\tcode{is_constructible_v} is \tcode{true}. \pnum \mandates @@ -2873,7 +2873,7 @@ \begin{itemize} \item If \tcode{has_value()} is \tcode{false}, returns -\tcode{expected(unexpect, std::move(error()))}. +\tcode{expected(unexpect, \removed{std::move(error())}\added{std::move(\exposid{unex}).error()})}. \item Otherwise, if \tcode{is_void_v} is \tcode{false}, returns an \tcode{expected} object whose \exposid{has_val} member is \tcode{true} and @@ -2921,14 +2921,14 @@ \begin{itemdescr} \pnum Let \tcode{G} be -\tcode{remove_cv_t>}. +\tcode{remove_cv_t>}. \pnum \mandates \tcode{G} is a valid template argument for \tcode{unexpected}\iref{expected.un.general} and the declaration \begin{codeblock} -G g(invoke(std::forward(f), std::move(error()))); +G g(invoke(std::forward(f), @\removed{std::move(error())}\added{std::move(\exposid{unex}).error()}@)); \end{codeblock} is well-formed. @@ -2937,7 +2937,7 @@ If \tcode{has_value()} is \tcode{true}, \tcode{expected()}; otherwise, an \tcode{expected} object whose \exposid{has_val} member is \tcode{false} and \exposid{unex} member is direct-non-list-initialized with -\tcode{invoke(std::for\-ward(f), std::move(error()))}. +\tcode{invoke(std::for\-ward(f), \removed{std::move(error())}\added{std::move(\exposid{unex}).error()})}. \end{itemdescr} \rSec3[expected.void.eq]{Equality operators} @@ -3501,7 +3501,7 @@ For the first overload, \tcode{bad_expected_access(as_const(error()))} if \tcode{has_value()} is \tcode{false}. For the second overload, -\tcode{bad_expected_access(std::move(error()))} if \tcode{has_value()} is +\tcode{bad_expected_access(std::move(\exposid{unex}).error())} if \tcode{has_value()} is \tcode{false}. Both overloads yield \tcode{T\&}; the value category of \tcode{*this} does not affect the returned reference. \end{itemdescr} From bfbc12cea7ed189feae7df08f73f3c5a9b8db630 Mon Sep 17 00:00:00 2001 From: Steve Downey Date: Mon, 30 Nov 2026 01:48:11 -0500 Subject: [PATCH 15/24] Record rvalue-error-binding as decided: std::move(unex).error() Steve Downey's ruling, why it is not std::move(*this).error(), where unex is and is not in scope, and what is left: the same-type move members' spelling, and the paper's prose for the 22 new marks. --- docs/plan/specgen-catchup.md | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/docs/plan/specgen-catchup.md b/docs/plan/specgen-catchup.md index 3c5cf660..90068620 100644 --- a/docs/plan/specgen-catchup.md +++ b/docs/plan/specgen-catchup.md @@ -1246,7 +1246,13 @@ Using `U` in *Mandates* also lets `--validate` match the authored **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.** OPEN +**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()))`, @@ -1260,6 +1266,7 @@ 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 @@ -1288,6 +1295,21 @@ is exact for both overloads is `decltype(std::move(*this).error())`. `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. ### specgen-pin From 61e1271aa25441cf73f55e58da84ac2ab341c24d Mon Sep 17 00:00:00 2001 From: Steve Downey Date: Mon, 30 Nov 2026 16:25:38 -0500 Subject: [PATCH 16/24] Follow optional in the base templates where a reference U, G or E was forgotten Checked expected against the small changes P2988R12 and its follow-up issues made to optional outside [optional.ref]. Each names a place where a deduced or parameter type may now be a reference and the base wording or code assumed it was not. Copying an expected or an unexpected from a const rvalue of its own type was a hard error under gcc-16. The deleted "would bind a temporary" constructor template deduced the class itself and had no guard for that, so its constraint depended on itself. It now carries the enabled overload's guards. transform_error accepts a callable that returns an lvalue reference and returns expected, as transform already returned expected, and as optional::transform returns optional. An rvalue reference result is still rejected; the four compile-fail tests now cover that case and are renamed for it. expected and expected assert that E, less any reference, is an object type, as expected and unexpected already did. Nothing that compiled is rejected: unexpected already refused a function type, after a less useful error. The docblocks, and so the generated wording, follow: - "valid value type" admits an lvalue reference to a non-array object type; - the transform docblocks have the draft's shape, with Mandates, and no longer name the in_place_t constructor, which expected deletes; - the move constructors and move assignment move rhs.unex, not rhs.error(); - value() Mandates test error-value-type, not E, and expected has them; - the deleted reference constructors are stated as optional states them: "This constructor is defined as deleted if ..."; - the synopsis declares unexpected and expected; - value() is freestanding-deleted in expected. --- include/beman/expected/expected.hpp | 230 ++++++++++++------ include/beman/expected/unexpected.hpp | 19 +- papers/wording/expected.tex | 121 +++++---- .../wording/fragments/expected.expected.tex | 36 ++- papers/wording/fragments/expected.ref.tex | 52 ++-- papers/wording/fragments/expected.syn.tex | 6 + .../wording/fragments/expected.unexpected.tex | 13 +- papers/wording/fragments/expected.void.tex | 14 +- tests/beman/expected/CMakeLists.txt | 16 +- ...h_transform_error_ref_result_fail.test.cpp | 10 - ...form_error_rvalue_ref_result_fail.test.cpp | 13 + ...e_transform_error_ref_result_fail.test.cpp | 10 - ...form_error_rvalue_ref_result_fail.test.cpp | 13 + ...f_transform_error_ref_result_fail.test.cpp | 10 - ...form_error_rvalue_ref_result_fail.test.cpp | 13 + .../expected_review_corrections.test.cpp | 126 ++++++++++ .../transform_error_ref_result_fail.test.cpp | 11 - ...form_error_rvalue_ref_result_fail.test.cpp | 12 + 18 files changed, 484 insertions(+), 241 deletions(-) delete mode 100644 tests/beman/expected/expected_ref_both_transform_error_ref_result_fail.test.cpp create mode 100644 tests/beman/expected/expected_ref_both_transform_error_rvalue_ref_result_fail.test.cpp delete mode 100644 tests/beman/expected/expected_ref_e_transform_error_ref_result_fail.test.cpp create mode 100644 tests/beman/expected/expected_ref_e_transform_error_rvalue_ref_result_fail.test.cpp delete mode 100644 tests/beman/expected/expected_ref_transform_error_ref_result_fail.test.cpp create mode 100644 tests/beman/expected/expected_ref_transform_error_rvalue_ref_result_fail.test.cpp delete mode 100644 tests/beman/expected/transform_error_ref_result_fail.test.cpp create mode 100644 tests/beman/expected/transform_error_rvalue_ref_result_fail.test.cpp diff --git a/include/beman/expected/expected.hpp b/include/beman/expected/expected.hpp index 43fa33e7..90f77d13 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 @@ -689,7 +699,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`. @@ -996,7 +1006,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: @@ -1349,7 +1359,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`. @@ -1373,8 +1383,9 @@ 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(unex).error())` if `has_value()` is //! `false`. @@ -1653,9 +1664,16 @@ constexpr auto expected::or_else(F&& f) const&& { //! \group monadic-transform-lval //! Let `U` be `remove_cv_t>`. //! \constraints `is_constructible_v` is `true`. -//! \effects Equivalent to: `if (!has_value()) return expected(unexpect, error()); else return expected(in_place, -//! invoke(std::forward(f), val));` +//! \mandates `U` is a valid value type for `expected`. If `is_void_v` is +//! `false`, the declaration `U u(invoke(std::forward(f), val));` is +//! well-formed. +//! \effects If `has_value()` is `false`, returns `expected(unexpect, +//! error())`. Otherwise, if `is_void_v` is `false`, returns an `expected` object whose `has_val` member is `true` and `val` member is +//! direct-non-list-initialized with `invoke(std::forward(f), val)`; if `U` +//! is an lvalue reference type, `val` instead points to the object to which +//! the result of that invocation refers. Otherwise, evaluates +//! `invoke(std::forward(f), val)` and then returns `expected()`. template template requires std::is_constructible_v @@ -1685,9 +1703,17 @@ constexpr auto expected::transform(F&& f) & { //! Let `U` be `remove_cv_t>`. //! \constraints `is_constructible_v` is //! `true`. -//! \effects Equivalent to: `if (!has_value()) return expected(unexpect, std::move(unex).error()); else return expected(in_place, -//! invoke(std::forward(f), std::move(val)));` +//! \mandates `U` is a valid value type for `expected`. If `is_void_v` is +//! `false`, the declaration `U u(invoke(std::forward(f), std::move(val)));` +//! is well-formed. +//! \effects If `has_value()` is `false`, returns `expected(unexpect, +//! std::move(unex).error())`. Otherwise, if `is_void_v` is `false`, returns +//! an `expected` object whose `has_val` member is `true` and `val` +//! member is direct-non-list-initialized with `invoke(std::forward(f), +//! std::move(val))`; if `U` is an lvalue reference type, `val` instead points +//! to the object to which the result of that invocation refers. Otherwise, +//! evaluates `invoke(std::forward(f), std::move(val))` and then returns +//! `expected()`. template template requires std::is_constructible_v @@ -1775,10 +1801,11 @@ template requires std::is_constructible_v constexpr auto expected::transform_error(F&& f) & { using G = std::remove_cv_t>; - static_assert(std::is_object_v, "transform_error: G must be an object type"); - static_assert(!std::is_array_v, "transform_error: G must not be an array type"); + static_assert(std::is_object_v> && !std::is_rvalue_reference_v, + "transform_error: G must be an object type or an lvalue reference to one"); + static_assert(!std::is_array_v>, "transform_error: G must not be an array type"); static_assert(std::is_same_v>, "transform_error: G must not be cv-qualified"); - static_assert(!detail::is_unexpected_specialization::value, + static_assert(!detail::is_unexpected_specialization>::value, "transform_error: G must not be a specialization of unexpected"); if (has_val_) return expected(std::in_place, val_); @@ -1796,10 +1823,11 @@ template requires std::is_constructible_v constexpr auto expected::transform_error(F&& f) && { using G = std::remove_cv_t>; - static_assert(std::is_object_v, "transform_error: G must be an object type"); - static_assert(!std::is_array_v, "transform_error: G must not be an array type"); + static_assert(std::is_object_v> && !std::is_rvalue_reference_v, + "transform_error: G must be an object type or an lvalue reference to one"); + static_assert(!std::is_array_v>, "transform_error: G must not be an array type"); static_assert(std::is_same_v>, "transform_error: G must not be cv-qualified"); - static_assert(!detail::is_unexpected_specialization::value, + static_assert(!detail::is_unexpected_specialization>::value, "transform_error: G must not be a specialization of unexpected"); if (has_val_) return expected(std::in_place, std::move(val_)); @@ -1812,10 +1840,11 @@ template requires std::is_constructible_v constexpr auto expected::transform_error(F&& f) const& { using G = std::remove_cv_t>; - static_assert(std::is_object_v, "transform_error: G must be an object type"); - static_assert(!std::is_array_v, "transform_error: G must not be an array type"); + static_assert(std::is_object_v> && !std::is_rvalue_reference_v, + "transform_error: G must be an object type or an lvalue reference to one"); + static_assert(!std::is_array_v>, "transform_error: G must not be an array type"); static_assert(std::is_same_v>, "transform_error: G must not be cv-qualified"); - static_assert(!detail::is_unexpected_specialization::value, + static_assert(!detail::is_unexpected_specialization>::value, "transform_error: G must not be a specialization of unexpected"); if (has_val_) return expected(std::in_place, val_); @@ -1828,10 +1857,11 @@ template requires std::is_constructible_v constexpr auto expected::transform_error(F&& f) const&& { using G = std::remove_cv_t>; - static_assert(std::is_object_v, "transform_error: G must be an object type"); - static_assert(!std::is_array_v, "transform_error: G must not be an array type"); + static_assert(std::is_object_v> && !std::is_rvalue_reference_v, + "transform_error: G must be an object type or an lvalue reference to one"); + static_assert(!std::is_array_v>, "transform_error: G must not be an array type"); static_assert(std::is_same_v>, "transform_error: G must not be cv-qualified"); - static_assert(!detail::is_unexpected_specialization::value, + static_assert(!detail::is_unexpected_specialization>::value, "transform_error: G must not be a specialization of unexpected"); if (has_val_) return expected(std::in_place, std::move(val_)); @@ -1863,6 +1893,7 @@ constexpr auto expected::transform_error(F&& f) const&& { //! \covers mandates !is_rvalue_reference_v //! \covers mandates !is_void_v> //! \covers mandates !is_array_v> +//! \covers mandates is_object_v> //! \covers mandates is_reference_v || is_same_v, E> //! \covers mandates !is-unexpected-specialization>>::value //! @@ -1873,6 +1904,7 @@ class expected { static_assert(!std::is_rvalue_reference_v, "E must not be an rvalue reference"); static_assert(!std::is_void_v>, "E must not be void"); 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"); static_assert(std::is_reference_v || std::is_same_v, E>, "E must not be cv-qualified"); static_assert(!detail::is_unexpected_specialization>>::value, "E must not be an unexpected specialization"); @@ -2292,7 +2324,7 @@ constexpr expected::expected(const expected& rhs) noexcept(std::is_noth //! \constraints `is_move_constructible_v` is `true` or //! `is_reference_v` is `true`. //! \effects If `rhs.has_value()` is `false`, 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 `unex`. @@ -2679,7 +2711,7 @@ constexpr void expected::operator*() const noexcept { } //! \freestanding-deleted -//! \mandates `is_copy_constructible_v` is `true`. +//! \mandates `is_copy_constructible_v` is `true`. //! \throws `bad_expected_access(error())` if `has_value()` is `false`. template constexpr void expected::value() const& { @@ -2689,8 +2721,8 @@ constexpr void expected::value() const& { } //! \freestanding-deleted -//! \mandates `is_copy_constructible_v` is `true` and -//! `is_move_constructible_v` is `true`. +//! \mandates `is_copy_constructible_v` is `true` and +//! `is_move_constructible_v` is `true`. //! \throws `bad_expected_access(std::move(unex).error())` if `has_value()` is //! `false`. template @@ -2910,13 +2942,15 @@ constexpr auto expected::or_else(F&& f) const&& { //! \group void-monadic-transform-lval //! Let `U` be `remove_cv_t>`. //! \constraints `is_constructible_v` is `true`. -//! \mandates `U` is a valid value type for `expected`. +//! \mandates `U` is a valid value type for `expected`. If `is_void_v` is +//! `false`, the declaration `U u(invoke(std::forward(f)));` is well-formed. //! \effects If `has_value()` is `false`, returns `expected(unexpect, -//! error())`. Otherwise, if `is_void_v` is `false`, returns an -//! `expected` object whose `has_val` member is `true` and `val` -//! member is direct-non-list-initialized with `invoke(std::forward(f))`. -//! Otherwise, evaluates `invoke(std::forward(f))` and then returns -//! `expected()`. +//! error())`. Otherwise, if `is_void_v` is `false`, returns an `expected` object whose `has_val` member is `true` and `val` member is +//! direct-non-list-initialized with `invoke(std::forward(f))`; if `U` is an +//! lvalue reference type, `val` instead points to the object to which the +//! result of that invocation refers. Otherwise, evaluates +//! `invoke(std::forward(f))` and then returns `expected()`. template template requires std::is_constructible_v @@ -2946,13 +2980,15 @@ constexpr auto expected::transform(F&& f) & { //! Let `U` be `remove_cv_t>`. //! \constraints `is_constructible_v` is //! `true`. -//! \mandates `U` is a valid value type for `expected`. +//! \mandates `U` is a valid value type for `expected`. If `is_void_v` is +//! `false`, the declaration `U u(invoke(std::forward(f)));` is well-formed. //! \effects If `has_value()` is `false`, returns `expected(unexpect, //! std::move(unex).error())`. Otherwise, if `is_void_v` is `false`, returns //! an `expected` object whose `has_val` member is `true` and `val` -//! member is direct-non-list-initialized with `invoke(std::forward(f))`. -//! Otherwise, evaluates `invoke(std::forward(f))` and then returns -//! `expected()`. +//! member is direct-non-list-initialized with `invoke(std::forward(f))`; if +//! `U` is an lvalue reference type, `val` instead points to the object to +//! which the result of that invocation refers. Otherwise, evaluates +//! `invoke(std::forward(f))` and then returns `expected()`. template template requires std::is_constructible_v @@ -3042,10 +3078,11 @@ template template constexpr auto expected::transform_error(F&& f) & { using G = std::remove_cv_t>; - static_assert(std::is_object_v, "transform_error: G must be an object type"); - static_assert(!std::is_array_v, "transform_error: G must not be an array type"); + static_assert(std::is_object_v> && !std::is_rvalue_reference_v, + "transform_error: G must be an object type or an lvalue reference to one"); + static_assert(!std::is_array_v>, "transform_error: G must not be an array type"); static_assert(std::is_same_v>, "transform_error: G must not be cv-qualified"); - static_assert(!detail::is_unexpected_specialization::value, + static_assert(!detail::is_unexpected_specialization>::value, "transform_error: G must not be a specialization of unexpected"); if (has_val_) return expected(); @@ -3064,10 +3101,11 @@ template template constexpr auto expected::transform_error(F&& f) && { using G = std::remove_cv_t>; - static_assert(std::is_object_v, "transform_error: G must be an object type"); - static_assert(!std::is_array_v, "transform_error: G must not be an array type"); + static_assert(std::is_object_v> && !std::is_rvalue_reference_v, + "transform_error: G must be an object type or an lvalue reference to one"); + static_assert(!std::is_array_v>, "transform_error: G must not be an array type"); static_assert(std::is_same_v>, "transform_error: G must not be cv-qualified"); - static_assert(!detail::is_unexpected_specialization::value, + static_assert(!detail::is_unexpected_specialization>::value, "transform_error: G must not be a specialization of unexpected"); if (has_val_) return expected(); @@ -3079,10 +3117,11 @@ template template constexpr auto expected::transform_error(F&& f) const& { using G = std::remove_cv_t>; - static_assert(std::is_object_v, "transform_error: G must be an object type"); - static_assert(!std::is_array_v, "transform_error: G must not be an array type"); + static_assert(std::is_object_v> && !std::is_rvalue_reference_v, + "transform_error: G must be an object type or an lvalue reference to one"); + static_assert(!std::is_array_v>, "transform_error: G must not be an array type"); static_assert(std::is_same_v>, "transform_error: G must not be cv-qualified"); - static_assert(!detail::is_unexpected_specialization::value, + static_assert(!detail::is_unexpected_specialization>::value, "transform_error: G must not be a specialization of unexpected"); if (has_val_) return expected(); @@ -3094,10 +3133,11 @@ template template constexpr auto expected::transform_error(F&& f) const&& { using G = std::remove_cv_t>; - static_assert(std::is_object_v, "transform_error: G must be an object type"); - static_assert(!std::is_array_v, "transform_error: G must not be an array type"); + static_assert(std::is_object_v> && !std::is_rvalue_reference_v, + "transform_error: G must be an object type or an lvalue reference to one"); + static_assert(!std::is_array_v>, "transform_error: G must not be an array type"); static_assert(std::is_same_v>, "transform_error: G must not be cv-qualified"); - static_assert(!detail::is_unexpected_specialization::value, + static_assert(!detail::is_unexpected_specialization>::value, "transform_error: G must not be a specialization of unexpected"); if (has_val_) return expected(); @@ -3205,12 +3245,13 @@ class expected { // Value constructor — takes U that can bind to T& //! \seebelow explicit //! \constraints `remove_cvref_t` is not `in_place_t`, `expected`, or - //! a specialization of `unexpected`; `is_constructible_v` is - //! `true`; and `reference_constructs_from_temporary_v` is - //! `false`. + //! a specialization of `unexpected`; and `is_constructible_v` is + //! `true`. //! \effects Let `r` be the lvalue result of `T& r = //! std::forward(u);`. Initializes `val` with `addressof(r)`. //! \ensures `has_value()` is `true`. + //! \remarks This constructor is defined as deleted if + //! `reference_constructs_from_temporary_v` is `true`. template requires(!std::is_same_v, std::in_place_t> && !std::is_same_v, expected> && @@ -3222,12 +3263,15 @@ class expected { val_ = std::addressof(r); } - // Deleted: binding a temporary to T& creates a dangling reference - //! \remarks A constructor for which - //! `reference_constructs_from_temporary_v` is `true` — one that - //! would bind `T&` to a temporary — is defined as deleted. + // Deleted: binding a temporary to T& creates a dangling reference. + // Represented in wording by the enabled overload above, whose \remarks + // says when it is deleted. + //! \merge template - requires(detail::reference_constructs_from_temporary_v) + requires(!std::is_same_v, std::in_place_t> && + !std::is_same_v, expected> && + !detail::is_unexpected_specialization>::value && + detail::reference_constructs_from_temporary_v) constexpr expected(U&&) = BEMAN_EXPECTED_DELETE_MSG( "expected: argument would bind a temporary that dangles; pass an lvalue reference"); @@ -4034,6 +4078,8 @@ constexpr bool expected::has_value() const noexcept { return has_val_; } +//! \freestanding-deleted +//! \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`. @@ -4045,6 +4091,10 @@ constexpr T& expected::value() const& { return *val_; } +//! \freestanding-deleted +//! \mandates `is_copy_constructible_v` is `true` and +//! `is_constructible_v` is `true`. //! \returns `*val` if `has_value()` is `true`. //! \throws `bad_expected_access(std::move(unex).error())` if `has_value()` is //! `false`. @@ -4288,9 +4338,16 @@ constexpr auto expected::or_else(F&& f) const&& { //! \group ref-monadic-transform-lval //! Let `U` be `remove_cv_t>`. //! \constraints `is_constructible_v` is `true`. -//! \effects Equivalent to: `if (!has_value()) return expected(unexpect, error()); else return expected(in_place, -//! invoke(std::forward(f), *val));` +//! \mandates `U` is a valid value type for `expected`. If `is_void_v` is +//! `false`, the declaration `U u(invoke(std::forward(f), *val));` is +//! well-formed. +//! \effects If `has_value()` is `false`, returns `expected(unexpect, +//! error())`. Otherwise, if `is_void_v` is `false`, returns an `expected` object whose `has_val` member is `true` and `val` member is +//! direct-non-list-initialized with `invoke(std::forward(f), *val)`; if `U` +//! is an lvalue reference type, `val` instead points to the object to which +//! the result of that invocation refers. Otherwise, evaluates +//! `invoke(std::forward(f), *val)` and then returns `expected()`. template template requires std::is_constructible_v @@ -4320,9 +4377,16 @@ constexpr auto expected::transform(F&& f) & { //! Let `U` be `remove_cv_t>`. //! \constraints `is_constructible_v` is //! `true`. -//! \effects Equivalent to: `if (!has_value()) return expected(unexpect, std::move(unex).error()); else return expected(in_place, -//! invoke(std::forward(f), *val));` +//! \mandates `U` is a valid value type for `expected`. If `is_void_v` is +//! `false`, the declaration `U u(invoke(std::forward(f), *val));` is +//! well-formed. +//! \effects If `has_value()` is `false`, returns `expected(unexpect, +//! std::move(unex).error())`. Otherwise, if `is_void_v` is `false`, returns +//! an `expected` object whose `has_val` member is `true` and `val` +//! member is direct-non-list-initialized with `invoke(std::forward(f), +//! *val)`; if `U` is an lvalue reference type, `val` instead points to the +//! object to which the result of that invocation refers. Otherwise, evaluates +//! `invoke(std::forward(f), *val)` and then returns `expected()`. template template requires std::is_constructible_v @@ -4408,10 +4472,11 @@ template template constexpr auto expected::transform_error(F&& f) & { using G = std::remove_cv_t>; - static_assert(std::is_object_v, "transform_error: G must be an object type"); - static_assert(!std::is_array_v, "transform_error: G must not be an array type"); + static_assert(std::is_object_v> && !std::is_rvalue_reference_v, + "transform_error: G must be an object type or an lvalue reference to one"); + static_assert(!std::is_array_v>, "transform_error: G must not be an array type"); static_assert(std::is_same_v>, "transform_error: G must not be cv-qualified"); - static_assert(!detail::is_unexpected_specialization::value, + static_assert(!detail::is_unexpected_specialization>::value, "transform_error: G must not be a specialization of unexpected"); if (has_val_) return expected(*val_); @@ -4426,10 +4491,11 @@ template template constexpr auto expected::transform_error(F&& f) && { using G = std::remove_cv_t>; - static_assert(std::is_object_v, "transform_error: G must be an object type"); - static_assert(!std::is_array_v, "transform_error: G must not be an array type"); + static_assert(std::is_object_v> && !std::is_rvalue_reference_v, + "transform_error: G must be an object type or an lvalue reference to one"); + static_assert(!std::is_array_v>, "transform_error: G must not be an array type"); static_assert(std::is_same_v>, "transform_error: G must not be cv-qualified"); - static_assert(!detail::is_unexpected_specialization::value, + static_assert(!detail::is_unexpected_specialization>::value, "transform_error: G must not be a specialization of unexpected"); if (has_val_) return expected(*val_); @@ -4441,10 +4507,11 @@ template template constexpr auto expected::transform_error(F&& f) const& { using G = std::remove_cv_t>; - static_assert(std::is_object_v, "transform_error: G must be an object type"); - static_assert(!std::is_array_v, "transform_error: G must not be an array type"); + static_assert(std::is_object_v> && !std::is_rvalue_reference_v, + "transform_error: G must be an object type or an lvalue reference to one"); + static_assert(!std::is_array_v>, "transform_error: G must not be an array type"); static_assert(std::is_same_v>, "transform_error: G must not be cv-qualified"); - static_assert(!detail::is_unexpected_specialization::value, + static_assert(!detail::is_unexpected_specialization>::value, "transform_error: G must not be a specialization of unexpected"); if (has_val_) return expected(*val_); @@ -4456,10 +4523,11 @@ template template constexpr auto expected::transform_error(F&& f) const&& { using G = std::remove_cv_t>; - static_assert(std::is_object_v, "transform_error: G must be an object type"); - static_assert(!std::is_array_v, "transform_error: G must not be an array type"); + static_assert(std::is_object_v> && !std::is_rvalue_reference_v, + "transform_error: G must be an object type or an lvalue reference to one"); + static_assert(!std::is_array_v>, "transform_error: G must not be an array type"); static_assert(std::is_same_v>, "transform_error: G must not be cv-qualified"); - static_assert(!detail::is_unexpected_specialization::value, + static_assert(!detail::is_unexpected_specialization>::value, "transform_error: G must not be a specialization of unexpected"); if (has_val_) return expected(*val_); diff --git a/include/beman/expected/unexpected.hpp b/include/beman/expected/unexpected.hpp index 3629e864..c4b78e6b 100644 --- a/include/beman/expected/unexpected.hpp +++ b/include/beman/expected/unexpected.hpp @@ -210,14 +210,12 @@ class unexpected { //! \at expected.un.ref //! \constraints //! \item `is_same_v, unexpected>` is `false`, - //! \item `is_same_v, in_place_t>` is `false`, - //! \item `is_constructible_v` is `true`, and - //! \item `reference_constructs_from_temporary_v` is `false`. + //! \item `is_same_v, in_place_t>` is `false`, and + //! \item `is_constructible_v` is `true`. //! \effects Initializes `unex` with //! `addressof(static_cast(std::forward(e)))`. - //! \remarks A constructor for which - //! `reference_constructs_from_temporary_v` is `true` — one that - //! would bind `E&` to a temporary — is defined as deleted. + //! \remarks This constructor is defined as deleted if + //! `reference_constructs_from_temporary_v` is `true`. template requires(!std::is_same_v, unexpected> && !std::is_same_v, std::in_place_t> && std::is_constructible_v && @@ -228,7 +226,9 @@ class unexpected { // enabled overload above, whose \remarks says when it's deleted instead. //! \merge template - requires(detail::reference_constructs_from_temporary_v) + requires(!std::is_same_v, unexpected> && + !std::is_same_v, std::in_place_t> && + detail::reference_constructs_from_temporary_v) constexpr unexpected(G&&) = BEMAN_EXPECTED_DELETE_MSG( "unexpected: argument would bind a temporary that dangles; pass an lvalue reference"); @@ -247,10 +247,11 @@ class unexpected { // reference or not. Naturally restricted to arity 1: there is no variadic overload here, // and expected only ever calls this when is_constructible_v already holds. //! \at expected.un.ref - //! \constraints `is_constructible_v` is `true` and - //! `reference_constructs_from_temporary_v` is `false`. + //! \constraints `is_constructible_v` is `true`. //! \effects Initializes `unex` with //! `addressof(static_cast(std::forward(e)))`. + //! \remarks This constructor is defined as deleted if + //! `reference_constructs_from_temporary_v` is `true`. template requires(std::is_constructible_v && !detail::reference_constructs_from_temporary_v) constexpr explicit unexpected(std::in_place_t, G&& e) noexcept diff --git a/papers/wording/expected.tex b/papers/wording/expected.tex index ca1ba872..457b8793 100644 --- a/papers/wording/expected.tex +++ b/papers/wording/expected.tex @@ -29,6 +29,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; @@ -46,6 +49,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{codeblock} @@ -289,9 +295,8 @@ \constraints \begin{itemize} \item \tcode{is_same_v, unexpected>} is \tcode{false}, -\item \tcode{is_same_v, in_place_t>} is \tcode{false}, -\item \tcode{is_constructible_v} is \tcode{true}, and -\item \tcode{reference_constructs_from_temporary_v} is \tcode{false}. +\item \tcode{is_same_v, in_place_t>} is \tcode{false}, and +\item \tcode{is_constructible_v} is \tcode{true}. \end{itemize} \pnum @@ -300,7 +305,7 @@ \pnum \remarks -A constructor for which \tcode{reference_constructs_from_temporary_v} is \tcode{true} — one that would bind \tcode{E\&} to a temporary — is defined as deleted. +This constructor is defined as deleted if \tcode{reference_constructs_from_temporary_v} is \tcode{true}. \end{itemdescr} \indexlibraryctor{unexpected}% @@ -312,11 +317,15 @@ \begin{itemdescr} \pnum \constraints -\tcode{is_constructible_v} is \tcode{true} and \tcode{reference_constructs_from_temporary_v} is \tcode{false}. +\tcode{is_constructible_v} is \tcode{true}. \pnum \effects Initializes \exposid{unex} with \tcode{addressof(static_cast(std::forward(e)))}. + +\pnum +\remarks +This constructor is defined as deleted if \tcode{reference_constructs_from_temporary_v} is \tcode{true}. \end{itemdescr} \indexlibrarymember{error}{unexpected}% @@ -666,7 +675,7 @@ When \tcode{has_value()} is \tcode{false}, the error is \tcode{\exposid{unex}.error()}. The error is held as an \tcode{unexpected}, and not as an \tcode{E}, so that \tcode{E} may be an lvalue reference type: an \tcode{E\&} cannot be a union member, whereas \tcode{unexpected} holds a pointer to an external object\iref{expected.un.ref}. \pnum -A type \tcode{T} is a \term{valid value type for \tcode{expected}}, if \tcode{remove_cv_t} is \tcode{void} or a complete non-array object type that is not \tcode{in_place_t}, \tcode{unexpect_t}, or a specialization of \tcode{unexpected}. A program which instantiates class template \tcode{expected} with an argument \tcode{T} that is not a valid value type for \tcode{expected} is ill-formed. A program that instantiates the definition of the template \tcode{expected} with a type for the \tcode{E} parameter that is not a valid template argument for \tcode{unexpected} is ill-formed. +A type \tcode{T} is a \term{valid value type for \tcode{expected}}, if \tcode{remove_cv_t} is \tcode{void} or a complete non-array object type that is not \tcode{in_place_t}, \tcode{unexpect_t}, or a specialization of \tcode{unexpected}, or if \tcode{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 \tcode{expected} with an argument \tcode{T} that is not a valid value type for \tcode{expected} is ill-formed. A program that instantiates the definition of the template \tcode{expected} with a type for the \tcode{E} parameter that is not a valid template argument for \tcode{unexpected} is ill-formed. \pnum When \tcode{T} is not \cv{} \tcode{void}, it shall meet the \oldconcept{Destructible} requirements (\tref{cpp17.destructible}). If \tcode{E} is not an lvalue reference type, \tcode{E} shall meet the \oldconcept{Destructible} requirements. @@ -734,7 +743,7 @@ \pnum \effects -If \tcode{rhs.has_value()} is \tcode{true}, direct-non-list-initializes \exposid{val} with \tcode{std::move(*rhs)}. Otherwise, direct-non-list-initializes \exposid{unex} with \tcode{std::move(rhs.error())}. +If \tcode{rhs.has_value()} is \tcode{true}, direct-non-list-initializes \exposid{val} with \tcode{std::move(*rhs)}. Otherwise, direct-non-list-initializes \exposid{unex} with \tcode{std::move(rhs.\exposid{unex})}. \pnum \ensures @@ -1085,7 +1094,7 @@ \pnum \effects -If \tcode{this->has_value() \&\& rhs.has_value()}, equivalent to \tcode{\exposid{val} = std::move(*rhs)}. Otherwise, if \tcode{this->has_value()}, equivalent to \tcode{reinit-expected(\exposid{unex}, \exposid{val}, std::move(rhs.error()))}. Otherwise, if \tcode{rhs.has_value()}, equivalent to \tcode{reinit-expected(\exposid{val}, \exposid{unex}, std::move(*rhs))}. Otherwise, equivalent to \tcode{\exposid{unex} = std::move(rhs.\exposid{unex})}. Then, if no exception was thrown, equivalent to: \tcode{\exposid{has_val} = rhs.has_value(); return *this;} When \tcode{E} is an lvalue reference type, each of the cases above that initializes or assigns \exposid{unex} rebinds it: \exposid{unex} comes to refer to the same object as \tcode{rhs}'s error. No previously or subsequently referenced object is assigned through. +If \tcode{this->has_value() \&\& rhs.has_value()}, equivalent to \tcode{\exposid{val} = std::move(*rhs)}. Otherwise, if \tcode{this->has_value()}, equivalent to \tcode{reinit-expected(\exposid{unex}, \exposid{val}, std::move(rhs.\exposid{unex}))}. Otherwise, if \tcode{rhs.has_value()}, equivalent to \tcode{reinit-expected(\exposid{val}, \exposid{unex}, std::move(*rhs))}. Otherwise, equivalent to \tcode{\exposid{unex} = std::move(rhs.\exposid{unex})}. Then, if no exception was thrown, equivalent to: \tcode{\exposid{has_val} = rhs.has_value(); return *this;} When \tcode{E} is an lvalue reference type, each of the cases above that initializes or assigns \exposid{unex} rebinds it: \exposid{unex} comes to refer to the same object as \tcode{rhs}'s error. No previously or subsequently referenced object is assigned through. \pnum \returns @@ -1340,7 +1349,7 @@ \begin{itemdescr} \pnum \mandates -\tcode{is_copy_constructible_v} is \tcode{true}. +\tcode{is_copy_constructible_v<\exposid{error-value-type}>} is \tcode{true}. \pnum \returns @@ -1360,7 +1369,7 @@ \begin{itemdescr} \pnum \mandates -\tcode{is_copy_constructible_v} is \tcode{true} and \tcode{is_constructible_v} is \tcode{true}. +\tcode{is_copy_constructible_v<\exposid{error-value-type}>} is \tcode{true} and \tcode{is_constructible_v<\exposid{error-value-type}, decltype(std::move(\exposid{unex}).error())>} is \tcode{true}. \pnum \returns @@ -1593,9 +1602,13 @@ \constraints \tcode{is_constructible_v} is \tcode{true}. +\pnum +\mandates +\tcode{U} is a valid value type for \tcode{expected}. If \tcode{is_void_v} is \tcode{false}, the declaration \tcode{U u(invoke(std::forward(f), \exposid{val}));} is well-formed. + \pnum \effects -Equivalent to: \tcode{if (!has_value()) return expected(unexpect, error()); else return expected(in_place, invoke(std::forward(f), \exposid{val}));} +If \tcode{has_value()} is \tcode{false}, returns \tcode{expected(unexpect, error())}. Otherwise, if \tcode{is_void_v} is \tcode{false}, returns an \tcode{expected} object whose \exposid{has_val} member is \tcode{true} and \exposid{val} member is direct-non-list-initialized with \tcode{invoke(std::forward(f), \exposid{val})}; if \tcode{U} is an lvalue reference type, \exposid{val} instead points to the object to which the result of that invocation refers. Otherwise, evaluates \tcode{invoke(std::forward(f), \exposid{val})} and then returns \tcode{expected()}. \end{itemdescr} \indexlibrarymember{transform}{expected}% @@ -1614,9 +1627,13 @@ \constraints \tcode{is_constructible_v} is \tcode{true}. +\pnum +\mandates +\tcode{U} is a valid value type for \tcode{expected}. If \tcode{is_void_v} is \tcode{false}, the declaration \tcode{U u(invoke(std::forward(f), std::move(\exposid{val})));} is well-formed. + \pnum \effects -Equivalent to: \tcode{if (!has_value()) return expected(unexpect, std::move(\exposid{unex}).error()); else return expected(in_place, invoke(std::forward(f), std::move(\exposid{val})));} +If \tcode{has_value()} is \tcode{false}, returns \tcode{expected(unexpect, std::move(\exposid{unex}).error())}. Otherwise, if \tcode{is_void_v} is \tcode{false}, returns an \tcode{expected} object whose \exposid{has_val} member is \tcode{true} and \exposid{val} member is direct-non-list-initialized with \tcode{invoke(std::forward(f), std::move(\exposid{val}))}; if \tcode{U} is an lvalue reference type, \exposid{val} instead points to the object to which the result of that invocation refers. Otherwise, evaluates \tcode{invoke(std::forward(f), std::move(\exposid{val}))} and then returns \tcode{expected()}. \end{itemdescr} \indexlibrarymember{transform_error}{expected}% @@ -1638,10 +1655,11 @@ \pnum \mandates \begin{itemize} -\item \tcode{is_object_v} is \tcode{true}, -\item \tcode{is_array_v} is \tcode{false}, +\item \tcode{is_object_v>} is \tcode{true}, +\item \tcode{is_rvalue_reference_v} is \tcode{false}, +\item \tcode{is_array_v>} is \tcode{false}, \item \tcode{is_same_v>} is \tcode{true}, -\item \tcode{\exposid{is-unexpected-specialization}::value} is \tcode{false}. +\item \tcode{\exposid{is-unexpected-specialization}>::value} is \tcode{false}. \end{itemize} \pnum @@ -1668,10 +1686,11 @@ \pnum \mandates \begin{itemize} -\item \tcode{is_object_v} is \tcode{true}, -\item \tcode{is_array_v} is \tcode{false}, +\item \tcode{is_object_v>} is \tcode{true}, +\item \tcode{is_rvalue_reference_v} is \tcode{false}, +\item \tcode{is_array_v>} is \tcode{false}, \item \tcode{is_same_v>} is \tcode{true}, -\item \tcode{\exposid{is-unexpected-specialization}::value} is \tcode{false}. +\item \tcode{\exposid{is-unexpected-specialization}>::value} is \tcode{false}. \end{itemize} \pnum @@ -1959,7 +1978,7 @@ \pnum \effects -If \tcode{rhs.has_value()} is \tcode{false}, direct-non-list-initializes \exposid{unex} with \tcode{std::move(rhs.error())}. +If \tcode{rhs.has_value()} is \tcode{false}, direct-non-list-initializes \exposid{unex} with \tcode{std::move(rhs.\exposid{unex})}. \pnum \ensures @@ -2406,7 +2425,7 @@ \begin{itemdescr} \pnum \mandates -\tcode{is_copy_constructible_v} is \tcode{true}. +\tcode{is_copy_constructible_v<\exposid{error-value-type}>} is \tcode{true}. \pnum \throws @@ -2421,7 +2440,7 @@ \begin{itemdescr} \pnum \mandates -\tcode{is_copy_constructible_v} is \tcode{true} and \tcode{is_move_constructible_v} is \tcode{true}. +\tcode{is_copy_constructible_v<\exposid{error-value-type}>} is \tcode{true} and \tcode{is_move_constructible_v<\exposid{error-value-type}>} is \tcode{true}. \pnum \throws @@ -2628,11 +2647,11 @@ \pnum \mandates -\tcode{U} is a valid value type for \tcode{expected}. +\tcode{U} is a valid value type for \tcode{expected}. If \tcode{is_void_v} is \tcode{false}, the declaration \tcode{U u(invoke(std::forward(f)));} is well-formed. \pnum \effects -If \tcode{has_value()} is \tcode{false}, returns \tcode{expected(unexpect, error())}. Otherwise, if \tcode{is_void_v} is \tcode{false}, returns an \tcode{expected} object whose \exposid{has_val} member is \tcode{true} and \tcode{val} member is direct-non-list-initialized with \tcode{invoke(std::forward(f))}. Otherwise, evaluates \tcode{invoke(std::forward(f))} and then returns \tcode{expected()}. +If \tcode{has_value()} is \tcode{false}, returns \tcode{expected(unexpect, error())}. Otherwise, if \tcode{is_void_v} is \tcode{false}, returns an \tcode{expected} object whose \exposid{has_val} member is \tcode{true} and \tcode{val} member is direct-non-list-initialized with \tcode{invoke(std::forward(f))}; if \tcode{U} is an lvalue reference type, \tcode{val} instead points to the object to which the result of that invocation refers. Otherwise, evaluates \tcode{invoke(std::forward(f))} and then returns \tcode{expected()}. \end{itemdescr} \indexlibrarymember{transform}{expected}% @@ -2653,11 +2672,11 @@ \pnum \mandates -\tcode{U} is a valid value type for \tcode{expected}. +\tcode{U} is a valid value type for \tcode{expected}. If \tcode{is_void_v} is \tcode{false}, the declaration \tcode{U u(invoke(std::forward(f)));} is well-formed. \pnum \effects -If \tcode{has_value()} is \tcode{false}, returns \tcode{expected(unexpect, std::move(\exposid{unex}).error())}. Otherwise, if \tcode{is_void_v} is \tcode{false}, returns an \tcode{expected} object whose \exposid{has_val} member is \tcode{true} and \tcode{val} member is direct-non-list-initialized with \tcode{invoke(std::forward(f))}. Otherwise, evaluates \tcode{invoke(std::forward(f))} and then returns \tcode{expected()}. +If \tcode{has_value()} is \tcode{false}, returns \tcode{expected(unexpect, std::move(\exposid{unex}).error())}. Otherwise, if \tcode{is_void_v} is \tcode{false}, returns an \tcode{expected} object whose \exposid{has_val} member is \tcode{true} and \tcode{val} member is direct-non-list-initialized with \tcode{invoke(std::forward(f))}; if \tcode{U} is an lvalue reference type, \tcode{val} instead points to the object to which the result of that invocation refers. Otherwise, evaluates \tcode{invoke(std::forward(f))} and then returns \tcode{expected()}. \end{itemdescr} \indexlibrarymember{transform_error}{expected}% @@ -2768,8 +2787,6 @@ template constexpr explicit(@\seebelow@) expected(U&& u) noexcept(is_nothrow_constructible_v); - template constexpr expected(U&&) = delete; - template constexpr explicit(@\seebelow@) expected(const expected& rhs); template constexpr explicit(@\seebelow@) expected(expected&& rhs); @@ -2850,8 +2867,8 @@ constexpr explicit operator bool() const noexcept; constexpr bool has_value() const noexcept; - constexpr T& value() const&; - constexpr T& value() &&; + constexpr T& value() const&; // freestanding-deleted + constexpr T& value() &&; // freestanding-deleted constexpr const E& error() const& noexcept; constexpr E& error() & noexcept; @@ -2973,7 +2990,7 @@ \begin{itemdescr} \pnum \constraints -\tcode{remove_cvref_t} is not \tcode{in_place_t}, \tcode{expected}, or a specialization of \tcode{unexpected}; \tcode{is_constructible_v} is \tcode{true}; and \tcode{reference_constructs_from_temporary_v} is \tcode{false}. +\tcode{remove_cvref_t} is not \tcode{in_place_t}, \tcode{expected}, or a specialization of \tcode{unexpected}; and \tcode{is_constructible_v} is \tcode{true}. \pnum \effects @@ -2982,22 +2999,10 @@ \pnum \ensures \tcode{has_value()} is \tcode{true}. -\end{itemdescr} - -\indexlibraryctor{expected}% -\begin{itemdecl} -template - constexpr expected(U&&) = delete; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\constraints -\tcode{reference_constructs_from_temporary_v} is \tcode{true}. \pnum \remarks -A constructor for which \tcode{reference_constructs_from_temporary_v} is \tcode{true} — one that would bind \tcode{T\&} to a temporary — is defined as deleted. +This constructor is defined as deleted if \tcode{reference_constructs_from_temporary_v} is \tcode{true}. \end{itemdescr} \indexlibraryctor{expected}% @@ -3441,6 +3446,10 @@ \end{itemdecl} \begin{itemdescr} +\pnum +\mandates +\tcode{is_copy_constructible_v<\exposid{error-value-type}>} is \tcode{true} and \tcode{is_constructible_v<\exposid{error-value-type}, decltype(std::move(\exposid{unex}).error())>} is \tcode{true}. + \pnum \returns \tcode{*\exposid{val}} if \tcode{has_value()} is \tcode{true}. @@ -3651,9 +3660,13 @@ \constraints \tcode{is_constructible_v} is \tcode{true}. +\pnum +\mandates +\tcode{U} is a valid value type for \tcode{expected}. If \tcode{is_void_v} is \tcode{false}, the declaration \tcode{U u(invoke(std::forward(f), *\exposid{val}));} is well-formed. + \pnum \effects -Equivalent to: \tcode{if (!has_value()) return expected(unexpect, error()); else return expected(in_place, invoke(std::forward(f), *\exposid{val}));} +If \tcode{has_value()} is \tcode{false}, returns \tcode{expected(unexpect, error())}. Otherwise, if \tcode{is_void_v} is \tcode{false}, returns an \tcode{expected} object whose \exposid{has_val} member is \tcode{true} and \exposid{val} member is direct-non-list-initialized with \tcode{invoke(std::forward(f), *\exposid{val})}; if \tcode{U} is an lvalue reference type, \exposid{val} instead points to the object to which the result of that invocation refers. Otherwise, evaluates \tcode{invoke(std::forward(f), *\exposid{val})} and then returns \tcode{expected()}. \end{itemdescr} \indexlibrarymember{transform}{expected}% @@ -3672,9 +3685,13 @@ \constraints \tcode{is_constructible_v} is \tcode{true}. +\pnum +\mandates +\tcode{U} is a valid value type for \tcode{expected}. If \tcode{is_void_v} is \tcode{false}, the declaration \tcode{U u(invoke(std::forward(f), *\exposid{val}));} is well-formed. + \pnum \effects -Equivalent to: \tcode{if (!has_value()) return expected(unexpect, std::move(\exposid{unex}).error()); else return expected(in_place, invoke(std::forward(f), *\exposid{val}));} +If \tcode{has_value()} is \tcode{false}, returns \tcode{expected(unexpect, std::move(\exposid{unex}).error())}. Otherwise, if \tcode{is_void_v} is \tcode{false}, returns an \tcode{expected} object whose \exposid{has_val} member is \tcode{true} and \exposid{val} member is direct-non-list-initialized with \tcode{invoke(std::forward(f), *\exposid{val})}; if \tcode{U} is an lvalue reference type, \exposid{val} instead points to the object to which the result of that invocation refers. Otherwise, evaluates \tcode{invoke(std::forward(f), *\exposid{val})} and then returns \tcode{expected()}. \end{itemdescr} \indexlibrarymember{transform_error}{expected}% @@ -3692,10 +3709,11 @@ \pnum \mandates \begin{itemize} -\item \tcode{is_object_v} is \tcode{true}, -\item \tcode{is_array_v} is \tcode{false}, +\item \tcode{is_object_v>} is \tcode{true}, +\item \tcode{is_rvalue_reference_v} is \tcode{false}, +\item \tcode{is_array_v>} is \tcode{false}, \item \tcode{is_same_v>} is \tcode{true}, -\item \tcode{\exposid{is-unexpected-specialization}::value} is \tcode{false}. +\item \tcode{\exposid{is-unexpected-specialization}>::value} is \tcode{false}. \end{itemize} \pnum @@ -3718,10 +3736,11 @@ \pnum \mandates \begin{itemize} -\item \tcode{is_object_v} is \tcode{true}, -\item \tcode{is_array_v} is \tcode{false}, +\item \tcode{is_object_v>} is \tcode{true}, +\item \tcode{is_rvalue_reference_v} is \tcode{false}, +\item \tcode{is_array_v>} is \tcode{false}, \item \tcode{is_same_v>} is \tcode{true}, -\item \tcode{\exposid{is-unexpected-specialization}::value} is \tcode{false}. +\item \tcode{\exposid{is-unexpected-specialization}>::value} is \tcode{false}. \end{itemize} \pnum diff --git a/papers/wording/fragments/expected.expected.tex b/papers/wording/fragments/expected.expected.tex index 0b1f225b..824aff6b 100644 --- a/papers/wording/fragments/expected.expected.tex +++ b/papers/wording/fragments/expected.expected.tex @@ -190,7 +190,7 @@ When \tcode{has_value()} is \tcode{false}, the error is \tcode{\exposid{unex}.error()}. The error is held as an \tcode{unexpected}, and not as an \tcode{E}, so that \tcode{E} may be an lvalue reference type: an \tcode{E\&} cannot be a union member, whereas \tcode{unexpected} holds a pointer to an external object\iref{expected.un.ref}. \pnum -A type \tcode{T} is a \term{valid value type for \tcode{expected}}, if \tcode{remove_cv_t} is \tcode{void} or a complete non-array object type that is not \tcode{in_place_t}, \tcode{unexpect_t}, or a specialization of \tcode{unexpected}. A program which instantiates class template \tcode{expected} with an argument \tcode{T} that is not a valid value type for \tcode{expected} is ill-formed. A program that instantiates the definition of the template \tcode{expected} with a type for the \tcode{E} parameter that is not a valid template argument for \tcode{unexpected} is ill-formed. +A type \tcode{T} is a \term{valid value type for \tcode{expected}}, if \tcode{remove_cv_t} is \tcode{void} or a complete non-array object type that is not \tcode{in_place_t}, \tcode{unexpect_t}, or a specialization of \tcode{unexpected}, or if \tcode{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 \tcode{expected} with an argument \tcode{T} that is not a valid value type for \tcode{expected} is ill-formed. A program that instantiates the definition of the template \tcode{expected} with a type for the \tcode{E} parameter that is not a valid template argument for \tcode{unexpected} is ill-formed. \pnum When \tcode{T} is not \cv{} \tcode{void}, it shall meet the \oldconcept{Destructible} requirements (\tref{cpp17.destructible}). If \tcode{E} is not an lvalue reference type, \tcode{E} shall meet the \oldconcept{Destructible} requirements. @@ -258,7 +258,7 @@ \pnum \effects -If \tcode{rhs.has_value()} is \tcode{true}, direct-non-list-initializes \exposid{val} with \tcode{std::move(*rhs)}. Otherwise, direct-non-list-initializes \exposid{unex} with \tcode{std::move(rhs.error())}. +If \tcode{rhs.has_value()} is \tcode{true}, direct-non-list-initializes \exposid{val} with \tcode{std::move(*rhs)}. Otherwise, direct-non-list-initializes \exposid{unex} with \tcode{std::move(rhs.\exposid{unex})}. \pnum \ensures @@ -609,7 +609,7 @@ \pnum \effects -If \tcode{this->has_value() \&\& rhs.has_value()}, equivalent to \tcode{\exposid{val} = std::move(*rhs)}. Otherwise, if \tcode{this->has_value()}, equivalent to \tcode{reinit-expected(\exposid{unex}, \exposid{val}, std::move(rhs.error()))}. Otherwise, if \tcode{rhs.has_value()}, equivalent to \tcode{reinit-expected(\exposid{val}, \exposid{unex}, std::move(*rhs))}. Otherwise, equivalent to \tcode{\exposid{unex} = std::move(rhs.\exposid{unex})}. Then, if no exception was thrown, equivalent to: \tcode{\exposid{has_val} = rhs.has_value(); return *this;} When \tcode{E} is an lvalue reference type, each of the cases above that initializes or assigns \exposid{unex} rebinds it: \exposid{unex} comes to refer to the same object as \tcode{rhs}'s error. No previously or subsequently referenced object is assigned through. +If \tcode{this->has_value() \&\& rhs.has_value()}, equivalent to \tcode{\exposid{val} = std::move(*rhs)}. Otherwise, if \tcode{this->has_value()}, equivalent to \tcode{reinit-expected(\exposid{unex}, \exposid{val}, std::move(rhs.\exposid{unex}))}. Otherwise, if \tcode{rhs.has_value()}, equivalent to \tcode{reinit-expected(\exposid{val}, \exposid{unex}, std::move(*rhs))}. Otherwise, equivalent to \tcode{\exposid{unex} = std::move(rhs.\exposid{unex})}. Then, if no exception was thrown, equivalent to: \tcode{\exposid{has_val} = rhs.has_value(); return *this;} When \tcode{E} is an lvalue reference type, each of the cases above that initializes or assigns \exposid{unex} rebinds it: \exposid{unex} comes to refer to the same object as \tcode{rhs}'s error. No previously or subsequently referenced object is assigned through. \pnum \returns @@ -864,7 +864,7 @@ \begin{itemdescr} \pnum \mandates -\tcode{is_copy_constructible_v} is \tcode{true}. +\tcode{is_copy_constructible_v<\exposid{error-value-type}>} is \tcode{true}. \pnum \returns @@ -884,7 +884,7 @@ \begin{itemdescr} \pnum \mandates -\tcode{is_copy_constructible_v} is \tcode{true} and \tcode{is_constructible_v} is \tcode{true}. +\tcode{is_copy_constructible_v<\exposid{error-value-type}>} is \tcode{true} and \tcode{is_constructible_v<\exposid{error-value-type}, decltype(std::move(\exposid{unex}).error())>} is \tcode{true}. \pnum \returns @@ -1117,9 +1117,13 @@ \constraints \tcode{is_constructible_v} is \tcode{true}. +\pnum +\mandates +\tcode{U} is a valid value type for \tcode{expected}. If \tcode{is_void_v} is \tcode{false}, the declaration \tcode{U u(invoke(std::forward(f), \exposid{val}));} is well-formed. + \pnum \effects -Equivalent to: \tcode{if (!has_value()) return expected(unexpect, error()); else return expected(in_place, invoke(std::forward(f), \exposid{val}));} +If \tcode{has_value()} is \tcode{false}, returns \tcode{expected(unexpect, error())}. Otherwise, if \tcode{is_void_v} is \tcode{false}, returns an \tcode{expected} object whose \exposid{has_val} member is \tcode{true} and \exposid{val} member is direct-non-list-initialized with \tcode{invoke(std::forward(f), \exposid{val})}; if \tcode{U} is an lvalue reference type, \exposid{val} instead points to the object to which the result of that invocation refers. Otherwise, evaluates \tcode{invoke(std::forward(f), \exposid{val})} and then returns \tcode{expected()}. \end{itemdescr} \indexlibrarymember{transform}{expected}% @@ -1138,9 +1142,13 @@ \constraints \tcode{is_constructible_v} is \tcode{true}. +\pnum +\mandates +\tcode{U} is a valid value type for \tcode{expected}. If \tcode{is_void_v} is \tcode{false}, the declaration \tcode{U u(invoke(std::forward(f), std::move(\exposid{val})));} is well-formed. + \pnum \effects -Equivalent to: \tcode{if (!has_value()) return expected(unexpect, std::move(\exposid{unex}).error()); else return expected(in_place, invoke(std::forward(f), std::move(\exposid{val})));} +If \tcode{has_value()} is \tcode{false}, returns \tcode{expected(unexpect, std::move(\exposid{unex}).error())}. Otherwise, if \tcode{is_void_v} is \tcode{false}, returns an \tcode{expected} object whose \exposid{has_val} member is \tcode{true} and \exposid{val} member is direct-non-list-initialized with \tcode{invoke(std::forward(f), std::move(\exposid{val}))}; if \tcode{U} is an lvalue reference type, \exposid{val} instead points to the object to which the result of that invocation refers. Otherwise, evaluates \tcode{invoke(std::forward(f), std::move(\exposid{val}))} and then returns \tcode{expected()}. \end{itemdescr} \indexlibrarymember{transform_error}{expected}% @@ -1162,10 +1170,11 @@ \pnum \mandates \begin{itemize} -\item \tcode{is_object_v} is \tcode{true}, -\item \tcode{is_array_v} is \tcode{false}, +\item \tcode{is_object_v>} is \tcode{true}, +\item \tcode{is_rvalue_reference_v} is \tcode{false}, +\item \tcode{is_array_v>} is \tcode{false}, \item \tcode{is_same_v>} is \tcode{true}, -\item \tcode{\exposid{is-unexpected-specialization}::value} is \tcode{false}. +\item \tcode{\exposid{is-unexpected-specialization}>::value} is \tcode{false}. \end{itemize} \pnum @@ -1192,10 +1201,11 @@ \pnum \mandates \begin{itemize} -\item \tcode{is_object_v} is \tcode{true}, -\item \tcode{is_array_v} is \tcode{false}, +\item \tcode{is_object_v>} is \tcode{true}, +\item \tcode{is_rvalue_reference_v} is \tcode{false}, +\item \tcode{is_array_v>} is \tcode{false}, \item \tcode{is_same_v>} is \tcode{true}, -\item \tcode{\exposid{is-unexpected-specialization}::value} is \tcode{false}. +\item \tcode{\exposid{is-unexpected-specialization}>::value} is \tcode{false}. \end{itemize} \pnum diff --git a/papers/wording/fragments/expected.ref.tex b/papers/wording/fragments/expected.ref.tex index 1715654f..924a88a3 100644 --- a/papers/wording/fragments/expected.ref.tex +++ b/papers/wording/fragments/expected.ref.tex @@ -29,8 +29,6 @@ template constexpr explicit(@\seebelow@) expected(U&& u) noexcept(is_nothrow_constructible_v); - template constexpr expected(U&&) = delete; - template constexpr explicit(@\seebelow@) expected(const expected& rhs); template constexpr explicit(@\seebelow@) expected(expected&& rhs); @@ -111,8 +109,8 @@ constexpr explicit operator bool() const noexcept; constexpr bool has_value() const noexcept; - constexpr T& value() const&; - constexpr T& value() &&; + constexpr T& value() const&; // freestanding-deleted + constexpr T& value() &&; // freestanding-deleted constexpr const E& error() const& noexcept; constexpr E& error() & noexcept; @@ -234,7 +232,7 @@ \begin{itemdescr} \pnum \constraints -\tcode{remove_cvref_t} is not \tcode{in_place_t}, \tcode{expected}, or a specialization of \tcode{unexpected}; \tcode{is_constructible_v} is \tcode{true}; and \tcode{reference_constructs_from_temporary_v} is \tcode{false}. +\tcode{remove_cvref_t} is not \tcode{in_place_t}, \tcode{expected}, or a specialization of \tcode{unexpected}; and \tcode{is_constructible_v} is \tcode{true}. \pnum \effects @@ -243,22 +241,10 @@ \pnum \ensures \tcode{has_value()} is \tcode{true}. -\end{itemdescr} - -\indexlibraryctor{expected}% -\begin{itemdecl} -template - constexpr expected(U&&) = delete; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\constraints -\tcode{reference_constructs_from_temporary_v} is \tcode{true}. \pnum \remarks -A constructor for which \tcode{reference_constructs_from_temporary_v} is \tcode{true} — one that would bind \tcode{T\&} to a temporary — is defined as deleted. +This constructor is defined as deleted if \tcode{reference_constructs_from_temporary_v} is \tcode{true}. \end{itemdescr} \indexlibraryctor{expected}% @@ -702,6 +688,10 @@ \end{itemdecl} \begin{itemdescr} +\pnum +\mandates +\tcode{is_copy_constructible_v<\exposid{error-value-type}>} is \tcode{true} and \tcode{is_constructible_v<\exposid{error-value-type}, decltype(std::move(\exposid{unex}).error())>} is \tcode{true}. + \pnum \returns \tcode{*\exposid{val}} if \tcode{has_value()} is \tcode{true}. @@ -912,9 +902,13 @@ \constraints \tcode{is_constructible_v} is \tcode{true}. +\pnum +\mandates +\tcode{U} is a valid value type for \tcode{expected}. If \tcode{is_void_v} is \tcode{false}, the declaration \tcode{U u(invoke(std::forward(f), *\exposid{val}));} is well-formed. + \pnum \effects -Equivalent to: \tcode{if (!has_value()) return expected(unexpect, error()); else return expected(in_place, invoke(std::forward(f), *\exposid{val}));} +If \tcode{has_value()} is \tcode{false}, returns \tcode{expected(unexpect, error())}. Otherwise, if \tcode{is_void_v} is \tcode{false}, returns an \tcode{expected} object whose \exposid{has_val} member is \tcode{true} and \exposid{val} member is direct-non-list-initialized with \tcode{invoke(std::forward(f), *\exposid{val})}; if \tcode{U} is an lvalue reference type, \exposid{val} instead points to the object to which the result of that invocation refers. Otherwise, evaluates \tcode{invoke(std::forward(f), *\exposid{val})} and then returns \tcode{expected()}. \end{itemdescr} \indexlibrarymember{transform}{expected}% @@ -933,9 +927,13 @@ \constraints \tcode{is_constructible_v} is \tcode{true}. +\pnum +\mandates +\tcode{U} is a valid value type for \tcode{expected}. If \tcode{is_void_v} is \tcode{false}, the declaration \tcode{U u(invoke(std::forward(f), *\exposid{val}));} is well-formed. + \pnum \effects -Equivalent to: \tcode{if (!has_value()) return expected(unexpect, std::move(\exposid{unex}).error()); else return expected(in_place, invoke(std::forward(f), *\exposid{val}));} +If \tcode{has_value()} is \tcode{false}, returns \tcode{expected(unexpect, std::move(\exposid{unex}).error())}. Otherwise, if \tcode{is_void_v} is \tcode{false}, returns an \tcode{expected} object whose \exposid{has_val} member is \tcode{true} and \exposid{val} member is direct-non-list-initialized with \tcode{invoke(std::forward(f), *\exposid{val})}; if \tcode{U} is an lvalue reference type, \exposid{val} instead points to the object to which the result of that invocation refers. Otherwise, evaluates \tcode{invoke(std::forward(f), *\exposid{val})} and then returns \tcode{expected()}. \end{itemdescr} \indexlibrarymember{transform_error}{expected}% @@ -953,10 +951,11 @@ \pnum \mandates \begin{itemize} -\item \tcode{is_object_v} is \tcode{true}, -\item \tcode{is_array_v} is \tcode{false}, +\item \tcode{is_object_v>} is \tcode{true}, +\item \tcode{is_rvalue_reference_v} is \tcode{false}, +\item \tcode{is_array_v>} is \tcode{false}, \item \tcode{is_same_v>} is \tcode{true}, -\item \tcode{\exposid{is-unexpected-specialization}::value} is \tcode{false}. +\item \tcode{\exposid{is-unexpected-specialization}>::value} is \tcode{false}. \end{itemize} \pnum @@ -979,10 +978,11 @@ \pnum \mandates \begin{itemize} -\item \tcode{is_object_v} is \tcode{true}, -\item \tcode{is_array_v} is \tcode{false}, +\item \tcode{is_object_v>} is \tcode{true}, +\item \tcode{is_rvalue_reference_v} is \tcode{false}, +\item \tcode{is_array_v>} is \tcode{false}, \item \tcode{is_same_v>} is \tcode{true}, -\item \tcode{\exposid{is-unexpected-specialization}::value} is \tcode{false}. +\item \tcode{\exposid{is-unexpected-specialization}>::value} is \tcode{false}. \end{itemize} \pnum diff --git a/papers/wording/fragments/expected.syn.tex b/papers/wording/fragments/expected.syn.tex index f392ffa6..83155113 100644 --- a/papers/wording/fragments/expected.syn.tex +++ b/papers/wording/fragments/expected.syn.tex @@ -6,6 +6,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; @@ -23,5 +26,8 @@ // \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{codeblock} diff --git a/papers/wording/fragments/expected.unexpected.tex b/papers/wording/fragments/expected.unexpected.tex index 1b68ad8a..2f00d049 100644 --- a/papers/wording/fragments/expected.unexpected.tex +++ b/papers/wording/fragments/expected.unexpected.tex @@ -238,9 +238,8 @@ \constraints \begin{itemize} \item \tcode{is_same_v, unexpected>} is \tcode{false}, -\item \tcode{is_same_v, in_place_t>} is \tcode{false}, -\item \tcode{is_constructible_v} is \tcode{true}, and -\item \tcode{reference_constructs_from_temporary_v} is \tcode{false}. +\item \tcode{is_same_v, in_place_t>} is \tcode{false}, and +\item \tcode{is_constructible_v} is \tcode{true}. \end{itemize} \pnum @@ -249,7 +248,7 @@ \pnum \remarks -A constructor for which \tcode{reference_constructs_from_temporary_v} is \tcode{true} — one that would bind \tcode{E\&} to a temporary — is defined as deleted. +This constructor is defined as deleted if \tcode{reference_constructs_from_temporary_v} is \tcode{true}. \end{itemdescr} \indexlibraryctor{unexpected}% @@ -261,11 +260,15 @@ \begin{itemdescr} \pnum \constraints -\tcode{is_constructible_v} is \tcode{true} and \tcode{reference_constructs_from_temporary_v} is \tcode{false}. +\tcode{is_constructible_v} is \tcode{true}. \pnum \effects Initializes \exposid{unex} with \tcode{addressof(static_cast(std::forward(e)))}. + +\pnum +\remarks +This constructor is defined as deleted if \tcode{reference_constructs_from_temporary_v} is \tcode{true}. \end{itemdescr} \indexlibrarymember{error}{unexpected}% diff --git a/papers/wording/fragments/expected.void.tex b/papers/wording/fragments/expected.void.tex index be6a813e..722f784f 100644 --- a/papers/wording/fragments/expected.void.tex +++ b/papers/wording/fragments/expected.void.tex @@ -223,7 +223,7 @@ \pnum \effects -If \tcode{rhs.has_value()} is \tcode{false}, direct-non-list-initializes \exposid{unex} with \tcode{std::move(rhs.error())}. +If \tcode{rhs.has_value()} is \tcode{false}, direct-non-list-initializes \exposid{unex} with \tcode{std::move(rhs.\exposid{unex})}. \pnum \ensures @@ -670,7 +670,7 @@ \begin{itemdescr} \pnum \mandates -\tcode{is_copy_constructible_v} is \tcode{true}. +\tcode{is_copy_constructible_v<\exposid{error-value-type}>} is \tcode{true}. \pnum \throws @@ -685,7 +685,7 @@ \begin{itemdescr} \pnum \mandates -\tcode{is_copy_constructible_v} is \tcode{true} and \tcode{is_move_constructible_v} is \tcode{true}. +\tcode{is_copy_constructible_v<\exposid{error-value-type}>} is \tcode{true} and \tcode{is_move_constructible_v<\exposid{error-value-type}>} is \tcode{true}. \pnum \throws @@ -892,11 +892,11 @@ \pnum \mandates -\tcode{U} is a valid value type for \tcode{expected}. +\tcode{U} is a valid value type for \tcode{expected}. If \tcode{is_void_v} is \tcode{false}, the declaration \tcode{U u(invoke(std::forward(f)));} is well-formed. \pnum \effects -If \tcode{has_value()} is \tcode{false}, returns \tcode{expected(unexpect, error())}. Otherwise, if \tcode{is_void_v} is \tcode{false}, returns an \tcode{expected} object whose \exposid{has_val} member is \tcode{true} and \tcode{val} member is direct-non-list-initialized with \tcode{invoke(std::forward(f))}. Otherwise, evaluates \tcode{invoke(std::forward(f))} and then returns \tcode{expected()}. +If \tcode{has_value()} is \tcode{false}, returns \tcode{expected(unexpect, error())}. Otherwise, if \tcode{is_void_v} is \tcode{false}, returns an \tcode{expected} object whose \exposid{has_val} member is \tcode{true} and \tcode{val} member is direct-non-list-initialized with \tcode{invoke(std::forward(f))}; if \tcode{U} is an lvalue reference type, \tcode{val} instead points to the object to which the result of that invocation refers. Otherwise, evaluates \tcode{invoke(std::forward(f))} and then returns \tcode{expected()}. \end{itemdescr} \indexlibrarymember{transform}{expected}% @@ -917,11 +917,11 @@ \pnum \mandates -\tcode{U} is a valid value type for \tcode{expected}. +\tcode{U} is a valid value type for \tcode{expected}. If \tcode{is_void_v} is \tcode{false}, the declaration \tcode{U u(invoke(std::forward(f)));} is well-formed. \pnum \effects -If \tcode{has_value()} is \tcode{false}, returns \tcode{expected(unexpect, std::move(\exposid{unex}).error())}. Otherwise, if \tcode{is_void_v} is \tcode{false}, returns an \tcode{expected} object whose \exposid{has_val} member is \tcode{true} and \tcode{val} member is direct-non-list-initialized with \tcode{invoke(std::forward(f))}. Otherwise, evaluates \tcode{invoke(std::forward(f))} and then returns \tcode{expected()}. +If \tcode{has_value()} is \tcode{false}, returns \tcode{expected(unexpect, std::move(\exposid{unex}).error())}. Otherwise, if \tcode{is_void_v} is \tcode{false}, returns an \tcode{expected} object whose \exposid{has_val} member is \tcode{true} and \tcode{val} member is direct-non-list-initialized with \tcode{invoke(std::forward(f))}; if \tcode{U} is an lvalue reference type, \tcode{val} instead points to the object to which the result of that invocation refers. Otherwise, evaluates \tcode{invoke(std::forward(f))} and then returns \tcode{expected()}. \end{itemdescr} \indexlibrarymember{transform_error}{expected}% diff --git a/tests/beman/expected/CMakeLists.txt b/tests/beman/expected/CMakeLists.txt index f0ae0045..7bdae574 100644 --- a/tests/beman/expected/CMakeLists.txt +++ b/tests/beman/expected/CMakeLists.txt @@ -219,8 +219,8 @@ beman_add_xfail_compile_test( LINK_LIBRARIES beman::expected ) beman_add_xfail_compile_test( - transform_error_ref_result_fail - SOURCE transform_error_ref_result_fail.test.cpp + transform_error_rvalue_ref_result_fail + SOURCE transform_error_rvalue_ref_result_fail.test.cpp LINK_LIBRARIES beman::expected ) @@ -370,8 +370,8 @@ beman_add_xfail_compile_test( LINK_LIBRARIES beman::expected ) beman_add_xfail_compile_test( - expected_ref_transform_error_ref_result_fail - SOURCE expected_ref_transform_error_ref_result_fail.test.cpp + expected_ref_transform_error_rvalue_ref_result_fail + SOURCE expected_ref_transform_error_rvalue_ref_result_fail.test.cpp LINK_LIBRARIES beman::expected ) @@ -419,8 +419,8 @@ beman_add_xfail_compile_test( LINK_LIBRARIES beman::expected ) beman_add_xfail_compile_test( - expected_ref_e_transform_error_ref_result_fail - SOURCE expected_ref_e_transform_error_ref_result_fail.test.cpp + expected_ref_e_transform_error_rvalue_ref_result_fail + SOURCE expected_ref_e_transform_error_rvalue_ref_result_fail.test.cpp LINK_LIBRARIES beman::expected ) @@ -468,8 +468,8 @@ beman_add_xfail_compile_test( LINK_LIBRARIES beman::expected ) beman_add_xfail_compile_test( - expected_ref_both_transform_error_ref_result_fail - SOURCE expected_ref_both_transform_error_ref_result_fail.test.cpp + expected_ref_both_transform_error_rvalue_ref_result_fail + SOURCE expected_ref_both_transform_error_rvalue_ref_result_fail.test.cpp LINK_LIBRARIES beman::expected ) diff --git a/tests/beman/expected/expected_ref_both_transform_error_ref_result_fail.test.cpp b/tests/beman/expected/expected_ref_both_transform_error_ref_result_fail.test.cpp deleted file mode 100644 index d2832629..00000000 --- a/tests/beman/expected/expected_ref_both_transform_error_ref_result_fail.test.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// NEGATIVE: transform_error on expected must return object type G, not reference -// EXPECT: "G must be an object type" -#include -void test() { - int err = 0; - beman::expected::expected e(beman::expected::unexpect, err); - // G = int& (reference type, not object type) - e.transform_error([](int& v) -> int& { return v; }); -} diff --git a/tests/beman/expected/expected_ref_both_transform_error_rvalue_ref_result_fail.test.cpp b/tests/beman/expected/expected_ref_both_transform_error_rvalue_ref_result_fail.test.cpp new file mode 100644 index 00000000..a2085e6e --- /dev/null +++ b/tests/beman/expected/expected_ref_both_transform_error_rvalue_ref_result_fail.test.cpp @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// NEGATIVE: transform_error on expected Mandates that G is a valid argument for +// unexpected. An lvalue reference is one; an rvalue reference is not. +// EXPECT: "G must be an object type or an lvalue reference to one" +#include +#include +void test() { + static int s = 0; + int err = 0; + beman::expected::expected e(beman::expected::unexpect, err); + // G = int&& + e.transform_error([](int&) -> int&& { return std::move(s); }); +} diff --git a/tests/beman/expected/expected_ref_e_transform_error_ref_result_fail.test.cpp b/tests/beman/expected/expected_ref_e_transform_error_ref_result_fail.test.cpp deleted file mode 100644 index deba573e..00000000 --- a/tests/beman/expected/expected_ref_e_transform_error_ref_result_fail.test.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// NEGATIVE: transform_error on expected must return object type G, not reference -// EXPECT: "G must be an object type" -#include -void test() { - int err = 0; - beman::expected::expected e(beman::expected::unexpect, err); - // G = int& (reference type, not object type) - e.transform_error([](int& v) -> int& { return v; }); -} diff --git a/tests/beman/expected/expected_ref_e_transform_error_rvalue_ref_result_fail.test.cpp b/tests/beman/expected/expected_ref_e_transform_error_rvalue_ref_result_fail.test.cpp new file mode 100644 index 00000000..f779110f --- /dev/null +++ b/tests/beman/expected/expected_ref_e_transform_error_rvalue_ref_result_fail.test.cpp @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// NEGATIVE: transform_error on expected Mandates that G is a valid argument for +// unexpected. An lvalue reference is one; an rvalue reference is not. +// EXPECT: "G must be an object type or an lvalue reference to one" +#include +#include +void test() { + static int s = 0; + int err = 0; + beman::expected::expected e(beman::expected::unexpect, err); + // G = int&& + e.transform_error([](int&) -> int&& { return std::move(s); }); +} diff --git a/tests/beman/expected/expected_ref_transform_error_ref_result_fail.test.cpp b/tests/beman/expected/expected_ref_transform_error_ref_result_fail.test.cpp deleted file mode 100644 index 290a389f..00000000 --- a/tests/beman/expected/expected_ref_transform_error_ref_result_fail.test.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// NEGATIVE: transform_error on expected must return object type G, not reference -// EXPECT: "G must be an object type" -#include -void test() { - int x = 0; - beman::expected::expected e(x); - // G = int& (reference type, not object type) - e.transform_error([](int& v) -> int& { return v; }); -} diff --git a/tests/beman/expected/expected_ref_transform_error_rvalue_ref_result_fail.test.cpp b/tests/beman/expected/expected_ref_transform_error_rvalue_ref_result_fail.test.cpp new file mode 100644 index 00000000..3ccd3cbf --- /dev/null +++ b/tests/beman/expected/expected_ref_transform_error_rvalue_ref_result_fail.test.cpp @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// NEGATIVE: transform_error on expected Mandates that G is a valid argument for +// unexpected. An lvalue reference is one; an rvalue reference is not. +// EXPECT: "G must be an object type or an lvalue reference to one" +#include +#include +void test() { + static int s = 0; + int x = 0; + beman::expected::expected e(x); + // G = int&& + e.transform_error([](int&) -> int&& { return std::move(s); }); +} diff --git a/tests/beman/expected/expected_review_corrections.test.cpp b/tests/beman/expected/expected_review_corrections.test.cpp index 09be30d4..c03ca897 100644 --- a/tests/beman/expected/expected_review_corrections.test.cpp +++ b/tests/beman/expected/expected_review_corrections.test.cpp @@ -523,3 +523,129 @@ TEST_CASE("rvalue and_then and transform rebind a referenced error", "[ref_e][mo REQUIRE(&r.error() == &s); } } + +// ============================================================================= +// A deleted constructor template that takes a forwarding reference deduces the +// class itself from a const rvalue of the same type. Its constraint then asked +// whether a temporary of the referent type could be made from the class, which +// under gcc depends on itself: copying from a const rvalue was a hard error and +// not a copy. The deleted overloads now carry the enabled overload's guards. +// ============================================================================= + +static_assert(std::is_constructible_v, const expected&&>); +static_assert(std::is_constructible_v, const expected&&>); +static_assert( + std::is_constructible_v, const expected&&>); +static_assert(std::is_constructible_v, const unexpected&&>); +// The guard does not reopen what the overload is there to delete. +static_assert(!std::is_constructible_v, std::string>); +static_assert(!std::is_constructible_v, const char*>); +static_assert(!std::is_constructible_v, std::string>); + +TEST_CASE("copying a reference expected from a const rvalue of its own type rebinds", "[ref][cons][shallow]") { + SECTION("expected") { + std::string s = "bar"; + const expected c{s}; + expected d{std::move(c)}; + REQUIRE(&*d == &s); + REQUIRE(s == "bar"); + } + SECTION("unexpected") { + std::string s = "bar"; + const unexpected c{s}; + unexpected d{std::move(c)}; + REQUIRE(&d.error() == &s); + REQUIRE(s == "bar"); + } + SECTION("expected, through its unexpected") { + std::string s = "bar"; + const expected c{unexpect, s}; + expected d{std::move(c)}; + REQUIRE(&d.error() == &s); + REQUIRE(s == "bar"); + } +} + +// ============================================================================= +// transform and transform_error leave the callable's result type a reference +// when it is one: remove_cv_t does not strip it. As optional::transform +// yields an optional, a callable that returns an lvalue reference yields an +// expected that refers to the same object. An rvalue reference is rejected. +// ============================================================================= + +TEST_CASE("transform with a callable returning an lvalue reference yields expected", "[monadic][ref]") { + std::string target = "target"; + SECTION("primary") { + expected e{1}; + auto r = e.transform([&](int&) -> std::string& { return target; }); + static_assert(std::is_same_v>); + REQUIRE(&*r == &target); + } + SECTION("primary, const result") { + expected e{1}; + auto r = std::move(e).transform([&](int&&) -> const std::string& { return target; }); + static_assert(std::is_same_v>); + REQUIRE(&*r == &target); + } + SECTION("void") { + expected e; + auto r = e.transform([&]() -> std::string& { return target; }); + static_assert(std::is_same_v>); + REQUIRE(&*r == &target); + } + SECTION("reference specialization") { + expected e{target}; + auto r = e.transform([](std::string& s) -> std::string& { return s; }); + static_assert(std::is_same_v>); + REQUIRE(&*r == &target); + } + SECTION("the error passes through") { + expected e{unexpect, 7}; + auto r = e.transform([&](int&) -> std::string& { return target; }); + REQUIRE(!r.has_value()); + REQUIRE(r.error() == 7); + } +} + +TEST_CASE("transform_error with a callable returning an lvalue reference yields expected", "[monadic][ref_e]") { + std::string target = "target"; + SECTION("primary") { + expected e{unexpect, 1}; + auto r = e.transform_error([&](int&) -> std::string& { return target; }); + static_assert(std::is_same_v>); + REQUIRE(&r.error() == &target); + } + SECTION("primary, const result from an rvalue") { + expected e{unexpect, 1}; + auto r = std::move(e).transform_error([&](int&&) -> const std::string& { return target; }); + static_assert(std::is_same_v>); + REQUIRE(&r.error() == &target); + } + SECTION("void") { + expected e{unexpect, 1}; + auto r = e.transform_error([&](int&) -> std::string& { return target; }); + static_assert(std::is_same_v>); + REQUIRE(&r.error() == &target); + } + SECTION("reference specialization") { + int v = 3; + expected e{unexpect, 1}; + auto r = e.transform_error([&](int&) -> std::string& { return target; }); + static_assert(std::is_same_v>); + REQUIRE(&r.error() == &target); + expected h{v}; + auto q = h.transform_error([&](int&) -> std::string& { return target; }); + REQUIRE(&*q == &v); + } + SECTION("a reference error, passed through unchanged") { + expected e{unexpect, target}; + auto r = e.transform_error([](std::string& s) -> std::string& { return s; }); + static_assert(std::is_same_v>); + REQUIRE(&r.error() == &target); + } + SECTION("the value passes through") { + expected e{5}; + auto r = e.transform_error([&](int&) -> std::string& { return target; }); + REQUIRE(*r == 5); + } +} diff --git a/tests/beman/expected/transform_error_ref_result_fail.test.cpp b/tests/beman/expected/transform_error_ref_result_fail.test.cpp deleted file mode 100644 index 5e5d8781..00000000 --- a/tests/beman/expected/transform_error_ref_result_fail.test.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// NEGATIVE: transform_error Mandates G is valid for unexpected (not a reference) -// EXPECT: "G must be an object type" -#include -void test() { - beman::expected::expected e(beman::expected::unexpect, 1); - e.transform_error([](int) -> int& { - static int x = 0; - return x; - }); -} diff --git a/tests/beman/expected/transform_error_rvalue_ref_result_fail.test.cpp b/tests/beman/expected/transform_error_rvalue_ref_result_fail.test.cpp new file mode 100644 index 00000000..ff82190f --- /dev/null +++ b/tests/beman/expected/transform_error_rvalue_ref_result_fail.test.cpp @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// NEGATIVE: transform_error on expected Mandates that G is a valid argument for +// unexpected. An lvalue reference is one; an rvalue reference is not. +// EXPECT: "G must be an object type or an lvalue reference to one" +#include +#include +void test() { + static int s = 0; + beman::expected::expected e(beman::expected::unexpect, 1); + // G = int&& + e.transform_error([](int) -> int&& { return std::move(s); }); +} From 9b8234d37cdceb1b7cf7917338443477649a5f5d Mon Sep 17 00:00:00 2001 From: Steve Downey Date: Mon, 30 Nov 2026 16:25:48 -0500 Subject: [PATCH 17/24] Mark the same corrections in the paper's wording Against the working draft, in expected-new.tex: - "valid value type" admits an lvalue reference to a non-array object type, and the four Returns of transform say what val is for a reference U; - the move constructors and the move assignment move rhs.unex where the draft has std::move(rhs.error()), which for a reference E hands an rvalue to unexpected; - the Constraints of swap admit a reference E whatever its referent; - the Mandates of value() test remove_cv_t>, since a trait on a reference E is vacuous; - a 23rd std::move(error()), in the Mandates of value() &&, which a \linebreak had hidden from the earlier search; - the synopsis declares unexpected and expected. In the added clauses: the deleted reference constructors are stated as optional states them, [expected.un.ref] requires an object type, and [expected.ref] gains Mandates for value() and marks it freestanding-deleted. --- papers/expected-new.tex | 84 +++++++++++++++++++++++++---------------- 1 file changed, 51 insertions(+), 33 deletions(-) diff --git a/papers/expected-new.tex b/papers/expected-new.tex index 0f171075..4463c7ef 100644 --- a/papers/expected-new.tex +++ b/papers/expected-new.tex @@ -21,6 +21,9 @@ // \ref{expected.unexpected}, class template \tcode{unexpected} template class unexpected; + @\added{// \ref{expected.un.ref}, partial specialization of \tcode{unexpected} for lvalue reference types}@ + @\added{template class unexpected;}@ + // \ref{expected.bad}, class template \tcode{bad_expected_access} template class bad_expected_access; @@ -38,6 +41,9 @@ // \ref{expected.void}, partial specialization of \tcode{expected} for \tcode{void} types template requires is_void_v class expected; // partially freestanding + + @\added{// \ref{expected.ref}, partial specialization of \tcode{expected} for lvalue reference types}@ + @\added{template class expected; // partially freestanding}@ } \end{codeblock} @@ -284,7 +290,7 @@ \pnum A program that instantiates the definition of \tcode{unexpected} for -an array type or a specialization of \tcode{unexpected} is ill-formed. +a type that is not an object type, an array type, or a specialization of \tcode{unexpected} is ill-formed. Unlike the primary template, \tcode{E} may be a cv-qualified type. \indexlibraryctor{unexpected}% @@ -298,9 +304,8 @@ \constraints \begin{itemize} \item \tcode{is_same_v, unexpected>} is \tcode{false}, -\item \tcode{is_same_v, in_place_t>} is \tcode{false}, -\item \tcode{is_constructible_v} is \tcode{true}, and -\item \tcode{reference_constructs_from_temporary_v} is \tcode{false}. +\item \tcode{is_same_v, in_place_t>} is \tcode{false}, and +\item \tcode{is_constructible_v} is \tcode{true}. \end{itemize} \pnum @@ -310,9 +315,8 @@ \pnum \remarks -A constructor for which -\tcode{reference_constructs_from_temporary_v} is \tcode{true} --- -one that would bind \tcode{E\&} to a temporary --- is defined as deleted. +This constructor is defined as deleted if +\tcode{reference_constructs_from_temporary_v} is \tcode{true}. \end{itemdescr} \indexlibraryctor{unexpected}% @@ -324,13 +328,17 @@ \begin{itemdescr} \pnum \constraints -\tcode{is_constructible_v} is \tcode{true} and -\tcode{reference_constructs_from_temporary_v} is \tcode{false}. +\tcode{is_constructible_v} is \tcode{true}. \pnum \effects Initializes \exposid{unex} with \tcode{addressof(static_cast(std::forward(e)))}. + +\pnum +\remarks +This constructor is defined as deleted if +\tcode{reference_constructs_from_temporary_v} is \tcode{true}. \end{itemdescr} \indexlibrarymember{error}{unexpected}% @@ -643,7 +651,8 @@ if \tcode{remove_cv_t} is \tcode{void} or a complete non-array object type that is not \tcode{in_place_t}, \tcode{unexpect_t}, -or a specialization of \tcode{unexpected}. +or a specialization of \tcode{unexpected}\added{, +or if \tcode{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 \tcode{expected} with an argument \tcode{T} that is not a valid value type for \tcode{expected} is ill-formed. @@ -748,7 +757,7 @@ If \tcode{rhs.has_value()} is \tcode{true}, direct-non-list-initializes \exposid{val} with \tcode{std::move(*rhs)}. Otherwise, -direct-non-list-initializes \exposid{unex} with \tcode{std::move(rhs.error())}. +direct-non-list-initializes \exposid{unex} with \tcode{\removed{std::move(rhs.error())}\added{std::move(rhs.\exposid{unex})}}. \pnum \ensures @@ -1158,7 +1167,7 @@ \item Otherwise, if \tcode{this->has_value()} is \tcode{true}, equivalent to: \begin{codeblock} -@\exposid{reinit-expected}@(@\exposid{unex}@, @\exposid{val}@, std::move(rhs.error())) +@\exposid{reinit-expected}@(@\exposid{unex}@, @\exposid{val}@, @\removed{std::move(rhs.error())}\added{std::move(rhs.\exposid{unex})}@) \end{codeblock} \item Otherwise, if \tcode{rhs.has_value()} is \tcode{true}, equivalent to: @@ -1355,7 +1364,7 @@ \item \tcode{is_swappable_v} is \tcode{true} and \item -\tcode{is_swappable_v} is \tcode{true} and +\tcode{is_swappable_v} is \tcode{true}\added{ or \tcode{is_reference_v} is \tcode{true}} and \item \tcode{is_move_constructible_v \&\& is_move_constructible_v} is \tcode{true}, and @@ -1506,7 +1515,7 @@ \begin{itemdescr} \pnum \mandates -\tcode{is_copy_constructible_v} is \tcode{true}. +\tcode{is_copy_constructible_v<\removed{E}\added{remove_cv_t>}>} is \tcode{true}. \pnum \returns @@ -1526,8 +1535,8 @@ \begin{itemdescr} \pnum \mandates -\tcode{is_copy_constructible_v} is \tcode{true} and -\tcode{is_constructible_v} is \tcode{true}. +\tcode{is_copy_constructible_v<\removed{E}\added{remove_cv_t>}>} is \tcode{true} and +\tcode{is_constructible_v<\removed{E}\added{remove_cv_t>}, decltype(\removed{std::move(error())}\added{std::move(\exposid{unex}).error()})>} is \tcode{true}. \pnum \returns @@ -1804,7 +1813,8 @@ Otherwise, if \tcode{is_void_v} is \tcode{false}, returns an \tcode{expected} object whose \exposid{has_val} member is \tcode{true} and \exposid{val} member is direct-non-list-initialized with -\tcode{invoke(std::forward(f), \exposid{val})}. +\tcode{invoke(std::forward(f), \exposid{val})}\added{; +if \tcode{U} is an lvalue reference type, \exposid{val} instead points to the object to which the result of that invocation refers}. \item Otherwise, evaluates \tcode{invoke(std::forward(f), \exposid{val})} and then returns \tcode{expected()}. @@ -1845,7 +1855,8 @@ Otherwise, if \tcode{is_void_v} is \tcode{false}, returns an \tcode{expected} object whose \exposid{has_val} member is \tcode{true} and \exposid{val} member is direct-non-list-initialized with -\tcode{invoke(std::forward(f), std::move(\exposid{val}))}. +\tcode{invoke(std::forward(f), std::move(\exposid{val}))}\added{; +if \tcode{U} is an lvalue reference type, \exposid{val} instead points to the object to which the result of that invocation refers}. \item Otherwise, evaluates \tcode{invoke(std::forward(f), std::move(\exposid{val}))} and then returns \tcode{ex\-pected()}. @@ -2157,7 +2168,7 @@ \pnum \effects If \tcode{rhs.has_value()} is \tcode{false}, -direct-non-list-initializes \exposid{unex} with \tcode{std::move(rhs.error())}. +direct-non-list-initializes \exposid{unex} with \tcode{\removed{std::move(rhs.error())}\added{std::move(rhs.\exposid{unex})}}. \pnum \ensures @@ -2511,7 +2522,7 @@ \begin{itemdescr} \pnum \constraints -\tcode{is_swappable_v} is \tcode{true} and +\tcode{is_swappable_v} is \tcode{true}\added{ or \tcode{is_reference_v} is \tcode{true}} and \tcode{is_move_constructible_v} is \tcode{true}. \pnum @@ -2594,7 +2605,7 @@ \begin{itemdescr} \pnum \mandates -\tcode{is_copy_constructible_v} is \tcode{true}. +\tcode{is_copy_constructible_v<\removed{E}\added{remove_cv_t>}>} is \tcode{true}. \pnum \throws @@ -2609,8 +2620,8 @@ \begin{itemdescr} \pnum \mandates -\tcode{is_copy_constructible_v} is \tcode{true} and -\tcode{is_move_constructible_v} is \tcode{true}. +\tcode{is_copy_constructible_v<\removed{E}\added{remove_cv_t>}>} is \tcode{true} and +\tcode{is_move_constructible_v<\removed{E}\added{remove_cv_t>}>} is \tcode{true}. \pnum \throws @@ -2838,7 +2849,8 @@ Otherwise, if \tcode{is_void_v} is \tcode{false}, returns an \tcode{expected} object whose \exposid{has_val} member is \tcode{true} and \exposid{val} member is direct-non-list-initialized with -\tcode{invoke(std::forward(f))}. +\tcode{invoke(std::forward(f))}\added{; +if \tcode{U} is an lvalue reference type, \exposid{val} instead points to the object to which the result of that invocation refers}. \item Otherwise, evaluates \tcode{invoke(std::forward(f))} and then returns \tcode{expected()}. @@ -2878,7 +2890,8 @@ Otherwise, if \tcode{is_void_v} is \tcode{false}, returns an \tcode{expected} object whose \exposid{has_val} member is \tcode{true} and \exposid{val} member is direct-non-list-initialized with -\tcode{invoke(std::forward(f))}. +\tcode{invoke(std::forward(f))}\added{; +if \tcode{U} is an lvalue reference type, \exposid{val} instead points to the object to which the result of that invocation refers}. \item Otherwise, evaluates \tcode{invoke(std::forward(f))} and then returns \tcode{expected()}. @@ -3043,8 +3056,8 @@ constexpr T& operator*() const noexcept; constexpr explicit operator bool() const noexcept; constexpr bool has_value() const noexcept; - constexpr T& value() const &; - constexpr T& value() &&; + constexpr T& value() const &; // freestanding-deleted + constexpr T& value() &&; // freestanding-deleted constexpr const E& error() const & noexcept; constexpr E& error() & noexcept; constexpr const E&& error() const && noexcept; @@ -3155,9 +3168,8 @@ \constraints \begin{itemize} \item \tcode{remove_cvref_t} is not \tcode{in_place_t}, -\tcode{expected}, or a specialization of \tcode{unexpected}; -\item \tcode{is_constructible_v} is \tcode{true}; and -\item \tcode{reference_constructs_from_temporary_v} is \tcode{false}. +\tcode{expected}, or a specialization of \tcode{unexpected}; and +\item \tcode{is_constructible_v} is \tcode{true}. \end{itemize} \pnum @@ -3173,9 +3185,8 @@ \remarks The expression inside \keyword{explicit} is equivalent to \tcode{!is_convertible_v}. -A constructor for which -\tcode{reference_constructs_from_temporary_v} is \tcode{true} --- -one that would bind \tcode{T\&} to a temporary --- is defined as deleted. +This constructor is defined as deleted if +\tcode{reference_constructs_from_temporary_v} is \tcode{true}. \end{itemdescr} \indexlibraryctor{expected}% @@ -3492,6 +3503,13 @@ \end{itemdecl} \begin{itemdescr} +\pnum +\mandates +\tcode{is_copy_constructible_v>>} is \tcode{true}. +For the second overload, +\tcode{is_constructible_v>, decltype(std::move(\exposid{unex}).error())>} +is also \tcode{true}. + \pnum \returns \tcode{*\exposid{val}} if \tcode{has_value()} is \tcode{true}. From a1261aba83ae817f0e9527da3f1e97ec18475f88 Mon Sep 17 00:00:00 2001 From: Steve Downey Date: Mon, 30 Nov 2026 16:25:48 -0500 Subject: [PATCH 18/24] Say in D4280 why the rvalue error accesses change, and what a reference result is The section on stealing covers the rvalue observers and monadic operations as well as conversions, and is retitled for that. It names the draft's std::move(error()) as access-then-move and std::move(unex).error() as its replacement. "Monadic operations are uniform" states that a callable returning an lvalue reference gives a reference expected, as for optional, and that the result can dangle, which is the callable's property and is left to the caller. A new short section says referents are non-array object types: optional admits arrays and functions and LWG4304 keeps that working, and this paper does not rewrite expected to follow without direction to do so. --- papers/D4280R0.tex | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/papers/D4280R0.tex b/papers/D4280R0.tex index 3f819932..234bf824 100644 --- a/papers/D4280R0.tex +++ b/papers/D4280R0.tex @@ -578,6 +578,14 @@ \section{\tcode{value\_or} returns by value; \tcode{error\_or} mirrors it} the reason instead of leaving the reader to infer it from ``no member named \tcode{value_or}.'' +\section{A referent is a non-array object type} + +\tcode{optional} admits a referent that is an array or a function, and \cite{LWG4304} adjusted its \tcode{value_or} so that such an \tcode{optional} is well-formed even though it cannot return its referent by value. +This paper does not rewrite \tcode{expected} to pick that up. +The referent of \tcode{expected}, and of a reference \tcode{E}, is an object type that is not an array, in line with what \tcode{expected} already requires of a value \tcode{T}. +Admitting the rest would mean reworking \tcode{value_or} and \tcode{error_or}, which return by value, and \tcode{value()}, whose exception carries a copy of the error. +That is not taken on here without explicit direction to do so. + \section{No default constructor, no in-place value, \tcode{emplace} rebinds} An engaged \tcode{expected} must hold a real reference; there is no null @@ -597,13 +605,21 @@ \section{Monadic operations are uniform} kept for parity with the primary template even though, for a reference, they do the same work. -\section{Shallow conversions must not steal} +A callable that returns an lvalue reference gives a reference result: \tcode{transform} returns \tcode{expected} and \tcode{transform_error} returns \tcode{expected}, each referring to the object the callable returned. +This follows \tcode{optional}, whose \tcode{transform} returns \tcode{optional} in the same case \cite{P2988R12}. +A result that is an rvalue reference is ill-formed. + +Such a result can dangle. +A callable can return a reference into the value or the error of an rvalue \tcode{expected}, or to anything else that does not outlive the result. +That is a property of the callable, and neither \tcode{expected} nor \tcode{optional} can detect it. +The same question was debated for \tcode{optional}, and the conclusion is the same here: the possibility of misuse does not warrant withholding the capability. -Converting a reference-holding \tcode{expected} to a value-holding one copies -the referent; it never moves out of it, even from an rvalue source. -\tcode{std::move} on an \tcode{expected} moves the handle --- a pointer ---- not the object it points at. This is the \tcode{boost::optional} -pitfall, stated as a guarantee callers may rely on: +\section{An rvalue \tcode{expected} must not let its referent be stolen} + +Converting a reference-holding \tcode{expected}, whether the reference is in the value or the error position, to a value-holding one copies the referent; it never moves out of it, even from an rvalue source. +Calling \tcode{std::move} on such an \tcode{expected} moves the handle --- a pointer --- not the object it points at. +Moving out of the referent is the \tcode{boost::optional} pitfall. +Here the copy is guaranteed: \begin{minted}[fontsize=\small]{c++} std::string s = "bar"; @@ -611,11 +627,14 @@ \section{Shallow conversions must not steal} std::expected v{std::move(r)}; // copies; s == "bar" afterwards \end{minted} -The internal rule that secures this is move-the-wrapper-then-access. For -example, use \tcode{*std::move(r)} or \tcode{std::move(r).error()}. Never use -access-then-move: \tcode{std::move(*r)} would force an rvalue onto a reference -the wrapper does not own, and steal from the caller's object. Because it is a -guarantee and not merely an implementation habit, it belongs in the design. +The internal rule that secures this is move-the-wrapper-then-access. +For example, use \tcode{*std::move(r)} or \tcode{std::move(r).error()}. +Never use access-then-move: \tcode{std::move(*r)} would create an rvalue reference to an object the wrapper does not own, making it possible to steal from the object the \tcode{expected} refers to. +Because it is a guarantee and not merely an implementation habit, it belongs in the design. + +The current wording spells the error of an rvalue \tcode{expected} as \tcode{std::move(error())}, which is access-then-move. +That was harmless while \tcode{E} could not be a reference. +The proposed wording replaces it with \tcode{std::move(unex).error()}, moving the exposition-only member, in \tcode{value}, \tcode{error_or}, and the monadic operations: the same type for an object \tcode{E}, and an lvalue for a reference \tcode{E}. \section{Deleted functions carry messages} From f616d7c3b4026cdad3939cb3162846c3062a1263 Mon Sep 17 00:00:00 2001 From: Steve Downey Date: Mon, 30 Nov 2026 16:25:48 -0500 Subject: [PATCH 19/24] Record reference-result-of-transform and the rest of the optional comparison The decision that transform and transform_error yield a reference expected for a callable returning an lvalue reference, as decided by the optional precedent, with what the same comparison found and changed. The log of rvalue-error-binding gains the 23rd mark and the corrected scope of the rebinding paragraph, which covers the move assignment and not the two move constructors. --- docs/plan/specgen-catchup.md | 44 ++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/docs/plan/specgen-catchup.md b/docs/plan/specgen-catchup.md index 90068620..e8f5f834 100644 --- a/docs/plan/specgen-catchup.md +++ b/docs/plan/specgen-catchup.md @@ -1310,6 +1310,50 @@ is exact for both overloads is `decltype(std::move(*this).error())`. 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 From 169b152179341ef0b69c751273262f214dacd2f8 Mon Sep 17 00:00:00 2001 From: Steve Downey Date: Mon, 30 Nov 2026 16:33:31 -0500 Subject: [PATCH 20/24] Spell four out-of-line constraints exactly as their declarations do MSVC 19.52 rejects four out-of-line definitions in expected with C2244 (bemanproject/expected#127): the value constructor, the value assignment and the two error_or overloads. Each definition's requires-clause named the class or its error-value-type with different tokens from the in-class declaration. The two are only functionally equivalent, which [temp.over.link] makes ill-formed, no diagnostic required. Clang 18 rejects the same four and nothing else in the header, which gives a way to check this without MSVC. The constructor and the assignment now say expected in the declaration too. error_or says remove_cv_t> in both, as expected and expected already did. Both spellings mean the same at class scope and at namespace scope, so neither relies on a leading requires-clause being looked up in the class, which no other definition in the header relies on either. Clang 18 goes from four errors in the header to none, in C++20, 23 and 26. Not verified with MSVC: there is no MSVC job in CI. The generated wording is unchanged. --- README.md | 18 ++++++++++-------- include/beman/expected/expected.hpp | 18 ++++++++++-------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 069b08cf..7821732e 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. That +has not been verified with MSVC itself: we do not have direct MSVC access and +there is no MSVC job in CI. 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/include/beman/expected/expected.hpp b/include/beman/expected/expected.hpp index 90f77d13..94cb04c9 100644 --- a/include/beman/expected/expected.hpp +++ b/include/beman/expected/expected.hpp @@ -265,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)) @@ -439,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 || @@ -546,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 @@ -1496,8 +1498,8 @@ constexpr T expected::value_or(U&& def) && { //! 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(); @@ -1512,8 +1514,8 @@ constexpr typename expected::error_value_type expected::error_or(G&& //! `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(); From 467a852b8139c76c51a2d069f5185d07c3a66656 Mon Sep 17 00:00:00 2001 From: Steve Downey Date: Mon, 30 Nov 2026 16:42:12 -0500 Subject: [PATCH 21/24] Build and test with MSVC in CI The MSVC jobs beman.typeclass runs, on the same reusable workflows: the msvc-debug and msvc-release presets on windows-latest, and a build-and-test entry for the latest MSVC at C++23 with Debug, Release, MaxSan and the modules build. The two MSVC presets set CMAKE_CXX_STANDARD to 23, as typeclass's do. The root preset is C++20, and MSVC has reference_constructs_from_temporary only as the C++23 library trait. This is what would have caught bemanproject/expected#127. Whether the rest of the library and its tests pass under MSVC is not known until these run. --- .github/workflows/ci_tests.yml | 20 +++++++++++++++++++- CMakePresets.json | 6 ++++-- README.md | 6 +++--- 3 files changed, 26 insertions(+), 6 deletions(-) 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/README.md b/README.md index 7821732e..fe38e787 100644 --- a/README.md +++ b/README.md @@ -76,9 +76,9 @@ builtin lands in **GCC 13** and **Clang 19**, which sets the floor: applies the same out-of-line-definition constraint-matching strictness as Clang 18 (`C2244: unable to match function definition to an existing declaration`). 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. That -has not been verified with MSVC itself: we do not have direct MSVC access and -there is no MSVC job in CI. Contributions with MSVC access are welcome. +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 From 3d05901284ace8d23d2306249c855d4c84310a3d Mon Sep 17 00:00:00 2001 From: Steve Downey Date: Mon, 30 Nov 2026 16:47:48 -0500 Subject: [PATCH 22/24] Keep a test case name ASCII so ctest can select it on Windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The first MSVC run compiled everything and failed one test of the 708 it reached: "expected: fully trivial — both sides are pointers". The library was not at fault. The name has an em dash, the only non-ASCII character in any test case name, and it did not survive the Windows command line that ctest passes it on, so Catch2 matched no test case and reported that none ran. ctest stops at the first failure, so the remaining 553 tests did not run. --- tests/beman/expected/expected_ref_both.test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/beman/expected/expected_ref_both.test.cpp b/tests/beman/expected/expected_ref_both.test.cpp index eb1683c4..dbf1cc7d 100644 --- a/tests/beman/expected/expected_ref_both.test.cpp +++ b/tests/beman/expected/expected_ref_both.test.cpp @@ -46,7 +46,7 @@ TEST_CASE("expected: special member availability", "[expected_ref_both]") CHECK(std::is_move_constructible_v>); } -TEST_CASE("expected: fully trivial — both sides are pointers", "[expected_ref_both]") { +TEST_CASE("expected: fully trivial - both sides are pointers", "[expected_ref_both]") { // Trivially copyable/movable/destructible CHECK(std::is_trivially_copy_constructible_v>); CHECK(std::is_trivially_move_constructible_v>); From 07116920db5a938848ecf329e93f0152b911c189 Mon Sep 17 00:00:00 2001 From: Steve Downey Date: Tue, 1 Dec 2026 07:54:00 -0500 Subject: [PATCH 23/24] Accept MSVC's deleted-function diagnostic in the initializer-list fail tests MSVC rejects expected(unexpect, {...}) on the deleted initializer-list overload with C2280, "attempting to reference a deleted function", which none of the three EXPECT patterns matched. Add the alternative the other deleted-function compile-fail tests already carry. --- .../expected/expected_ref_both_initializer_list_fail.test.cpp | 2 +- .../expected/expected_ref_e_initializer_list_fail.test.cpp | 2 +- .../expected/expected_void_ref_e_initializer_list_fail.test.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/beman/expected/expected_ref_both_initializer_list_fail.test.cpp b/tests/beman/expected/expected_ref_both_initializer_list_fail.test.cpp index 96c1e212..56721ed8 100644 --- a/tests/beman/expected/expected_ref_both_initializer_list_fail.test.cpp +++ b/tests/beman/expected/expected_ref_both_initializer_list_fail.test.cpp @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // NEGATIVE: expected initializer-list error construction: E& cannot bind to the list -// EXPECT: "initializer-list error construction cannot bind a reference|use of deleted function|call to deleted" +// EXPECT: "initializer-list error construction cannot bind a reference|use of deleted function|call to deleted|attempting to reference" #include using namespace beman::expected; diff --git a/tests/beman/expected/expected_ref_e_initializer_list_fail.test.cpp b/tests/beman/expected/expected_ref_e_initializer_list_fail.test.cpp index f9707a40..8e95bd5d 100644 --- a/tests/beman/expected/expected_ref_e_initializer_list_fail.test.cpp +++ b/tests/beman/expected/expected_ref_e_initializer_list_fail.test.cpp @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // NEGATIVE: expected initializer-list error construction: E& cannot bind to the list -// EXPECT: "initializer-list error construction cannot bind a reference|use of deleted function|call to deleted" +// EXPECT: "initializer-list error construction cannot bind a reference|use of deleted function|call to deleted|attempting to reference" #include using namespace beman::expected; diff --git a/tests/beman/expected/expected_void_ref_e_initializer_list_fail.test.cpp b/tests/beman/expected/expected_void_ref_e_initializer_list_fail.test.cpp index 57070f18..68660cff 100644 --- a/tests/beman/expected/expected_void_ref_e_initializer_list_fail.test.cpp +++ b/tests/beman/expected/expected_void_ref_e_initializer_list_fail.test.cpp @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // NEGATIVE: expected initializer-list error construction: E& cannot bind to the list -// EXPECT: "initializer-list error construction cannot bind a reference|use of deleted function|call to deleted" +// EXPECT: "initializer-list error construction cannot bind a reference|use of deleted function|call to deleted|attempting to reference" #include using namespace beman::expected; From d39ec764bbd8940fbba3754af6c74d68b10e396b Mon Sep 17 00:00:00 2001 From: Steve Downey Date: Tue, 1 Dec 2026 08:16:42 -0500 Subject: [PATCH 24/24] Put MSVC's wording on its own EXPECT line so clang-format leaves it alone Adding the alternative made each of the three EXPECT lines 136 columns. The limit is 119 and ReflowComments is on, so the pre-commit check rewrapped the comment, which would cut the pattern in two. The driver joins every EXPECT line of a file with "|", and other tests already use two lines for this, so the first line goes back to what it was and the new alternative gets a line of its own. The pattern the driver reads is unchanged. --- .../expected/expected_ref_both_initializer_list_fail.test.cpp | 3 ++- .../expected/expected_ref_e_initializer_list_fail.test.cpp | 3 ++- .../expected_void_ref_e_initializer_list_fail.test.cpp | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/beman/expected/expected_ref_both_initializer_list_fail.test.cpp b/tests/beman/expected/expected_ref_both_initializer_list_fail.test.cpp index 56721ed8..fde1ce6f 100644 --- a/tests/beman/expected/expected_ref_both_initializer_list_fail.test.cpp +++ b/tests/beman/expected/expected_ref_both_initializer_list_fail.test.cpp @@ -1,6 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // NEGATIVE: expected initializer-list error construction: E& cannot bind to the list -// EXPECT: "initializer-list error construction cannot bind a reference|use of deleted function|call to deleted|attempting to reference" +// EXPECT: "initializer-list error construction cannot bind a reference|use of deleted function|call to deleted" +// EXPECT: "attempting to reference" #include using namespace beman::expected; diff --git a/tests/beman/expected/expected_ref_e_initializer_list_fail.test.cpp b/tests/beman/expected/expected_ref_e_initializer_list_fail.test.cpp index 8e95bd5d..66c4c54a 100644 --- a/tests/beman/expected/expected_ref_e_initializer_list_fail.test.cpp +++ b/tests/beman/expected/expected_ref_e_initializer_list_fail.test.cpp @@ -1,6 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // NEGATIVE: expected initializer-list error construction: E& cannot bind to the list -// EXPECT: "initializer-list error construction cannot bind a reference|use of deleted function|call to deleted|attempting to reference" +// EXPECT: "initializer-list error construction cannot bind a reference|use of deleted function|call to deleted" +// EXPECT: "attempting to reference" #include using namespace beman::expected; diff --git a/tests/beman/expected/expected_void_ref_e_initializer_list_fail.test.cpp b/tests/beman/expected/expected_void_ref_e_initializer_list_fail.test.cpp index 68660cff..d9ea55e5 100644 --- a/tests/beman/expected/expected_void_ref_e_initializer_list_fail.test.cpp +++ b/tests/beman/expected/expected_void_ref_e_initializer_list_fail.test.cpp @@ -1,6 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // NEGATIVE: expected initializer-list error construction: E& cannot bind to the list -// EXPECT: "initializer-list error construction cannot bind a reference|use of deleted function|call to deleted|attempting to reference" +// EXPECT: "initializer-list error construction cannot bind a reference|use of deleted function|call to deleted" +// EXPECT: "attempting to reference" #include using namespace beman::expected;