From d3a872cc3f0a7cde11b9ab2b59e20a50a290aa0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Kr=C3=BCgler?= Date: Tue, 19 Sep 2023 17:37:40 +0200 Subject: [PATCH] Improve proposed wording by replacing operator*() by directly referring to the corresponding union member. --- xml/issue3973.xml | 70 +++++++++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 32 deletions(-) diff --git a/xml/issue3973.xml b/xml/issue3973.xml index b5cd0ddced..a288aa06fb 100644 --- a/xml/issue3973.xml +++ b/xml/issue3973.xml @@ -20,6 +20,12 @@ don't direct use **this, but use the name of the union member instead. Moreover, will change the monadic operations of std::optional to use **this, which is also problematic.

+ +2023-09-19; Wording update +

+Several people preferred to replace operator*() by the corresponding union members, so this part of the proposed wording +has been adjusted, which is a rather mechanical replacement. +

@@ -33,7 +39,7 @@ This wording is relative to .

-[Drafting note: Effectively replace all occurrences of **this by operator*().] +[Drafting note: Effectively replace all occurrences of **this by val.]

@@ -44,7 +50,7 @@ template<class F> constexpr auto and_then(F&& f) const &;

--1- Let U be remove_cvref_t<invoke_result_t<F, decltype(**thisoperator*())>>. +-1- Let U be remove_cvref_t<invoke_result_t<F, decltype(**thisval)>>.

-2- […]

@@ -54,7 +60,7 @@ template<class F> constexpr auto and_then(F&& f) const &;

 if (has_value())
-  return invoke(std::forward<F>(f), **thisoperator*());
+  return invoke(std::forward<F>(f), **thisval);
 else
   return U(unexpect, error());
 
@@ -65,7 +71,7 @@ template<class F> constexpr auto and_then(F&& f) const &&;

--5- Let U be remove_cvref_t<invoke_result_t<F, decltype((std::move(**thisoperator*()))>>. +-5- Let U be remove_cvref_t<invoke_result_t<F, decltype((std::move(**thisval))>>.

-6- […]

@@ -75,7 +81,7 @@ template<class F> constexpr auto and_then(F&& f) const &&;

 if (has_value())
-  return invoke(std::forward<F>(f), std::move(**thisoperator*()));
+  return invoke(std::forward<F>(f), std::move(**thisval));
 else
   return U(unexpect, std::move(error()));
 
@@ -88,7 +94,7 @@ template<class F> constexpr auto or_else(F&& f) const &;

-9- Let G be remove_cvref_t<invoke_result_t<F, decltype(error())>>.

--10- Constraints: is_constructible_v<T, decltype(**thisoperator*())> is true. +-10- Constraints: is_constructible_v<T, decltype(**thisval)> is true.

-11- […]

@@ -96,7 +102,7 @@ template<class F> constexpr auto or_else(F&& f) const &;

 if (has_value())
-  return G(in_place, **thisoperator*());
+  return G(in_place, **thisval);
 else
   return invoke(std::forward<F>(f), error());
 
@@ -109,7 +115,7 @@ template<class F> constexpr auto or_else(F&& f) const &&;

-13- Let G be remove_cvref_t<invoke_result_t<F, decltype(std::move(error()))>>.

--14- Constraints: is_constructible_v<T, decltype(std::move(**thisoperator*()))> is true. +-14- Constraints: is_constructible_v<T, decltype(std::move(**thisval))> is true.

-15- […]

@@ -117,7 +123,7 @@ template<class F> constexpr auto or_else(F&& f) const &&;

 if (has_value())
-  return G(in_place, std::move(**thisoperator*()));
+  return G(in_place, std::move(**thisval));
 else
   return invoke(std::forward<F>(f), std::move(error()));
 
@@ -128,7 +134,7 @@ template<class F> constexpr auto transform(F&& f) const &;

--17- Let U be remove_cvref_t<invoke_result_t<F, decltype(**thisoperator*())>>. +-17- Let U be remove_cvref_t<invoke_result_t<F, decltype(**thisval)>>.

-18- […]

@@ -136,7 +142,7 @@ template<class F> constexpr auto transform(F&& f) const &; the declaration

-U u(invoke(std::forward<F>(f), **thisoperator*()));
+U u(invoke(std::forward<F>(f), **thisval));
 

is well-formed. @@ -147,8 +153,8 @@ is well-formed.

  • (20.1) — […]

  • (20.2) — Otherwise, if is_void_v<U> is false, returns an expected<U, E> object whose has_val member is true and val member is direct-non-list-initialized -with invoke(std::forward<F>(f), **thisoperator*()).

  • -
  • (20.3) — Otherwise, evaluates invoke(std::forward<F>(f), **thisoperator*()) +with invoke(std::forward<F>(f), **thisval).

  • +
  • (20.3) — Otherwise, evaluates invoke(std::forward<F>(f), **thisval) and then returns expected<U, E>().

  • @@ -158,7 +164,7 @@ template<class F> constexpr auto transform(F&& f) const &&

    --21- Let U be remove_cvref_t<invoke_result_t<F, decltype(std::move(**thisoperator*()))>>. +-21- Let U be remove_cvref_t<invoke_result_t<F, decltype(std::move(**thisval))>>.

    -22- […]

    @@ -166,7 +172,7 @@ template<class F> constexpr auto transform(F&& f) const && the declaration

    -U u(invoke(std::forward<F>(f), std::move(**thisoperator*())));
    +U u(invoke(std::forward<F>(f), std::move(**thisval)));
     

    is well-formed. @@ -177,8 +183,8 @@ is well-formed.

  • (24.1) — […]

  • (24.2) — Otherwise, if is_void_v<U> is false, returns an expected<U, E> object whose has_val member is true and val member is direct-non-list-initialized -with invoke(std::forward<F>(f), std::move(**thisoperator*())).

  • -
  • (24.3) — Otherwise, evaluates invoke(std::forward<F>(f), std::move(**thisoperator*())) +with invoke(std::forward<F>(f), std::move(**thisval)).

  • +
  • (24.3) — Otherwise, evaluates invoke(std::forward<F>(f), std::move(**thisval)) and then returns expected<U, E>().

  • @@ -190,11 +196,11 @@ template<class F> constexpr auto transform_error(F&& f) const &

    -25- Let G be remove_cvref_t<invoke_result_t<F, decltype(error())>>.

    --26- Constraints: is_constructible_v<T, decltype(**thisoperator*())> is true. +-26- Constraints: is_constructible_v<T, decltype(**thisval)> is true.

    -27- Mandates: […]

    --28- Returns: If has_value() is true, expected<T, G>(in_place, **thisoperator*()); +-28- Returns: If has_value() is true, expected<T, G>(in_place, **thisval); otherwise, an expected<T, G> object whose has_val member is false and unex member is direct-non-list-initialized with invoke(std::forward<F>(f), error()).

    @@ -207,11 +213,11 @@ template<class F> constexpr auto transform_error(F&& f) const &

    -29- Let G be remove_cvref_t<invoke_result_t<F, decltype(std::move(error()))>>.

    --30- Constraints: is_constructible_v<T, decltype(std::move(**thisoperator*()))> is true. +-30- Constraints: is_constructible_v<T, decltype(std::move(**thisval))> is true.

    -31- Mandates: […]

    --32- Returns: If has_value() is true, expected<T, G>(in_place, std::move(**thisoperator*())); +-32- Returns: If has_value() is true, expected<T, G>(in_place, std::move(**thisval)); otherwise, an expected<T, G> object whose has_val member is false and unex member is direct-non-list-initialized with invoke(std::forward<F>(f), std::move(error())).

    @@ -224,7 +230,7 @@ otherwise, an expected<T, G> object whose has_val

    -[Drafting note: Effectively replace all occurrences of value() by operator*().] +[Drafting note: Effectively replace all occurrences of value() by *val.]

    @@ -235,7 +241,7 @@ template<class F> constexpr auto and_then(F&& f) const &;

    --1- Let U be invoke_result_t<F, decltype(value()operator*())>. +-1- Let U be invoke_result_t<F, decltype(value()*val)>.

    -2- […]

    @@ -243,7 +249,7 @@ template<class F> constexpr auto and_then(F&& f) const &;

     if (*this) {
    -  return invoke(std::forward<F>(f), value()operator*());
    +  return invoke(std::forward<F>(f), value()*val);
     } else {
       return remove_cvref_t<U>();
     }
    @@ -255,7 +261,7 @@ template<class F> constexpr auto and_then(F&& f) const &&;
     

    --4- Let U be invoke_result_t<F, decltype(std::move(value()operator*()))>. +-4- Let U be invoke_result_t<F, decltype(std::move(value()*val))>.

    -5- […]

    @@ -263,7 +269,7 @@ template<class F> constexpr auto and_then(F&& f) const &&;

     if (*this) {
    -  return invoke(std::forward<F>(f), std::move(value()operator*()));
    +  return invoke(std::forward<F>(f), std::move(value()*val));
     } else {
       return remove_cvref_t<U>();
     }
    @@ -275,12 +281,12 @@ template<class F> constexpr auto transform(F&& f) const &;
     

    --7- Let U be remove_cv_t<invoke_result_t<F, decltype(value()operator*())>>. +-7- Let U be remove_cv_t<invoke_result_t<F, decltype(value()*val)>>.

    -8- Mandates: U is a non-array object type other than in_place_t or nullopt_t. The declaration

    -U u(invoke(std::forward<F>(f), value()operator*()));
    +U u(invoke(std::forward<F>(f), value()*val));
     

    is well-formed for some invented variable u. @@ -288,7 +294,7 @@ is well-formed for some invented variable u. […]

    -9- Returns: If *this contains a value, an optional<U> object whose contained value is -direct-non-list-initialized with invoke(std::forward<F>(f), value()operator*()); otherwise, +direct-non-list-initialized with invoke(std::forward<F>(f), value()*val); otherwise, optional<U>().

    @@ -298,12 +304,12 @@ template<class F> constexpr auto transform(F&& f) const &&

    --10- Let U be remove_cv_t<invoke_result_t<F, decltype(std::move(value()operator*()))>>. +-10- Let U be remove_cv_t<invoke_result_t<F, decltype(std::move(value()*val))>>.

    -11- Mandates: U is a non-array object type other than in_place_t or nullopt_t. The declaration

    -U u(invoke(std::forward<F>(f), std::move(value()operator*())));
    +U u(invoke(std::forward<F>(f), std::move(value()*val)));
     

    is well-formed for some invented variable u. @@ -311,7 +317,7 @@ is well-formed for some invented variable u. […]

    -12- Returns: If *this contains a value, an optional<U> object whose contained value is -direct-non-list-initialized with invoke(std::forward<F>(f), std::move(value()operator*())); otherwise, +direct-non-list-initialized with invoke(std::forward<F>(f), std::move(value()*val)); otherwise, optional<U>().