C++ Logo

std-proposals

Advanced search

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

From: Mital Ashok <mital_at_[hidden]>
Date: Tue, 2 Jun 2026 03:42:07 +0100
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
>

Received on 2026-06-02 02:42:25