C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Function-bound objects with unary operator %

From: Andre Kostur <andre_at_[hidden]>
Date: Mon, 1 Jun 2026 19:48:58 -0700
What's the type of the expression "%std::async( EntryPoint )"? Also,
isn't this next door to VLAs, and one reason we don't like VLAs is the
near potentially unbounded automatic storage consumption (since alloca
has been mentioned)?

In addition to: I'm not in favour of this "feature" as it is messing
with visible (or in this case: invisible) lifetimes.

On Mon, Jun 1, 2026 at 7:42 PM Mital Ashok via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> It will be an uphill battle adding a new operator (that presumably won't be overloadable?) since this looks like it will be a pretty niche feature, unlike structured bindings.
>
> Consider a syntax like `::new (std::function_scope) T /* initialiser */`. This also extends to VLA-like alloca `::new (std::function_scope) T[/* non-constant expression */]` if you are looking to support that as well. This should require no new grammar.
>
> On Mon, 1 Jun 2026, 22:41 Frederick Virchanza Gotham via Std-Proposals, <std-proposals_at_[hidden]> wrote:
>>
>> On Mon, Jun 1, 2026 at 3:53 PM Sebastian Wittmeier wrote:
>> >
>> > Would it have to be a language feature?
>> >
>> > Can't you just define an object managing a linked list with alloca? And calling a member function to append a new object?
>> >
>> > If you define the object in the most-outer scope of the function, it would live until the function returns and could free the other objects (wait for the futures) in its constructor.
>> >
>> > Why is new syntax needed?
>>
>>
>> Well the unary operator '%' is programmed to become "classalloca( )",
>> so you can write "classalloca( std::async( EntryPoint ) )" instead of
>> "%std::async(EntryPoint)".
>>
>> I think the unary operator is cool for this though. Like how
>> structured bindings didn't add any functionality at all to the
>> language but were just deemed cool enough to make it in.
>> --
>> Std-Proposals mailing list
>> Std-Proposals_at_[hidden]
>> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2026-06-02 02:49:11