Date: Fri, 4 Sep 2026 01:15:54 +0800 (CST)
``[](this &x) { decltype(x) x; }``
is the same as
``
struct __lambda001 {
auto operator()(this __lambda001& x)
{
decltype(x) y; // can't be just `decltype(x) x`.
}
} __temp_lambda001 { };
``
Is there any problem?
Of course anyone can operate on any class type within a member function of that class before it's complete and before the return type of the member function is known.
To implement `struct this& x` or `this &x` without that feature being implemented by the compiler, just use `this CLASS_NAME& x` with a `#define CLASS_NAME /* enclosing class name here */` ahead and `undef` that macro afterwards.
>Message: 2
>Date: Thu, 3 Sep 2026 18:46:09 +0200
>From: Jan Schultke <janschultke_at_[hidden]>
>To: std-proposals_at_[hidden]
>Cc: Bingzhi <bingzhi2025_at_[hidden]>
>Subject: Re: [std-proposals] An abbreviatted explicit object
> parameter:'struct this'
>Message-ID:
>I once pondered this idea as well, and people raised concerns about the
>implementability for lambdas. If you're able to write something like
>[](this &x) { decltype(x) x; }
>it means you are able to operate on the type of the lambda before it's
>complete and before the return type of its function call operator is known.
>I've been told it's quite problematic. Also keep in mind that due to
>implicit capturing, you don't really know the contents of the lambda before
>the end of the expression, so some two-phase parsing is needed.
>I generally support the idea, but someone needs to figure out the details
>and how this could be implemented.
is the same as
``
struct __lambda001 {
auto operator()(this __lambda001& x)
{
decltype(x) y; // can't be just `decltype(x) x`.
}
} __temp_lambda001 { };
``
Is there any problem?
Of course anyone can operate on any class type within a member function of that class before it's complete and before the return type of the member function is known.
To implement `struct this& x` or `this &x` without that feature being implemented by the compiler, just use `this CLASS_NAME& x` with a `#define CLASS_NAME /* enclosing class name here */` ahead and `undef` that macro afterwards.
>Message: 2
>Date: Thu, 3 Sep 2026 18:46:09 +0200
>From: Jan Schultke <janschultke_at_[hidden]>
>To: std-proposals_at_[hidden]
>Cc: Bingzhi <bingzhi2025_at_[hidden]>
>Subject: Re: [std-proposals] An abbreviatted explicit object
> parameter:'struct this'
>Message-ID:
>I once pondered this idea as well, and people raised concerns about the
>implementability for lambdas. If you're able to write something like
>[](this &x) { decltype(x) x; }
>it means you are able to operate on the type of the lambda before it's
>complete and before the return type of its function call operator is known.
>I've been told it's quite problematic. Also keep in mind that due to
>implicit capturing, you don't really know the contents of the lambda before
>the end of the expression, so some two-phase parsing is needed.
>I generally support the idea, but someone needs to figure out the details
>and how this could be implemented.
Received on 2026-09-03 17:16:12
