Date: Mon, 18 Apr 2022 17:53:40 +0100
I don't see any contradiction. The this keyword and the this parameter are
distinct entities, so they don't have to have the same value category.
On Mon, 18 Apr 2022, 17:45 Anoop Rana via Std-Proposals, <
std-proposals_at_[hidden]> wrote:
> There seems to be a contradiction between the two statements from the
> standard as described below:
>
> From class.this#1 <https://timsong-cpp.github.io/cppwp/n4659/class.this#1>
> :
> > In the body of a non-static member function, the keyword this is a *prvalue
> expression* whose value is the address of the object for which the
> function is called...
>
> But in the same document at expr.call#4
> <https://timsong-cpp.github.io/cppwp/n4659/expr.call#4>:
>
> > When a function is called, each parameter ([dcl.fct]) shall be
> initialized ([dcl.init], [class.copy], [class.ctor]) with its corresponding
> argument. *If the function is a non-static member function, the `this`
> parameter of the function shall be initialized* with a pointer to the
> object of the call, converted as if by an explicit type conversion...
>
> ---
>
> Now we know that if we have a function parameter named `var`, then the
> value category of that parameter `var`(as an expression) is an *lvalue*.
> Thus, reading the 2nd quoted statement above(that implies that a non-static
> member function has a `this` parameter), the same should apply to the
> `this` parameter. In particular, if `this` is indeed a parameter of a
> non-static member function then its value category(as an expression) should
> be *lvalue* which contradicts with the first quoted statement that says
> `this` is a *prvalue expression.*
>
> The problem comes due to the use of the phrase "`this` parameter" in the
> second quoted statement above. So how should this be rectified given that
> the contradiction follows naturally from the two quoted statements.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
distinct entities, so they don't have to have the same value category.
On Mon, 18 Apr 2022, 17:45 Anoop Rana via Std-Proposals, <
std-proposals_at_[hidden]> wrote:
> There seems to be a contradiction between the two statements from the
> standard as described below:
>
> From class.this#1 <https://timsong-cpp.github.io/cppwp/n4659/class.this#1>
> :
> > In the body of a non-static member function, the keyword this is a *prvalue
> expression* whose value is the address of the object for which the
> function is called...
>
> But in the same document at expr.call#4
> <https://timsong-cpp.github.io/cppwp/n4659/expr.call#4>:
>
> > When a function is called, each parameter ([dcl.fct]) shall be
> initialized ([dcl.init], [class.copy], [class.ctor]) with its corresponding
> argument. *If the function is a non-static member function, the `this`
> parameter of the function shall be initialized* with a pointer to the
> object of the call, converted as if by an explicit type conversion...
>
> ---
>
> Now we know that if we have a function parameter named `var`, then the
> value category of that parameter `var`(as an expression) is an *lvalue*.
> Thus, reading the 2nd quoted statement above(that implies that a non-static
> member function has a `this` parameter), the same should apply to the
> `this` parameter. In particular, if `this` is indeed a parameter of a
> non-static member function then its value category(as an expression) should
> be *lvalue* which contradicts with the first quoted statement that says
> `this` is a *prvalue expression.*
>
> The problem comes due to the use of the phrase "`this` parameter" in the
> second quoted statement above. So how should this be rectified given that
> the contradiction follows naturally from the two quoted statements.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
Received on 2022-04-18 16:53:54