C++ Logo

std-proposals

Advanced search

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

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Mon, 1 Jun 2026 22:41:15 +0100
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.

Received on 2026-06-01 21:41:29