Date: Tue, 21 May 2024 12:04:12 -0300
Hey folks,
If you're willing to abuse structured binding syntax, you can inject a
post-initialization function in get<0>, like this:
https://godbolt.org/z/qa1n8a5x5
It's not great that the caller syntax is a weird single member structure
binding, but the code generation for this case is optimal (only because the
functor has no data members and everything is inlined though).
Bit out there, but I can see this trick could be used in a real codebase.
Best Regards,
Breno G.
On Tue, May 21, 2024 at 10:15 AM Sebastian Wittmeier via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> Another more flexible variant could be a
>
> template<class T>
> std::forward_modified(Callable getter, Callable modifier);
>
>
> which would not construct the initial object by itself, but take the
> return value of another function as argument (with guaranteed RVO).
>
> return std::forward_modified(getmutex, lockit);
>
>
>
>
>
> -----Ursprüngliche Nachricht-----
> *Von:* Frederick Virchanza Gotham via Std-Proposals <
> std-proposals_at_[hidden]>
> *Gesendet:* Di 21.05.2024 00:00
> *Betreff:* Re: [std-proposals] std::elide
> *An:* std-proposals_at_[hidden];
> *CC:* Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>;
> On Mon, May 20, 2024 at 9:51 PM Sebastian Wittmeier via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
> >
> > This feature request could be also made to a standard library function.
> >
> > // Calls the constructor and a setup function. With guaranteed RVO.
> >
> > T std::factory<T>(params, ..., setup)
> >
> > No need for other language changes or any special exception handling.
>
>
> I've tried to implement it here:
>
> https://godbolt.org/z/v99dvGqnn
>
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
If you're willing to abuse structured binding syntax, you can inject a
post-initialization function in get<0>, like this:
https://godbolt.org/z/qa1n8a5x5
It's not great that the caller syntax is a weird single member structure
binding, but the code generation for this case is optimal (only because the
functor has no data members and everything is inlined though).
Bit out there, but I can see this trick could be used in a real codebase.
Best Regards,
Breno G.
On Tue, May 21, 2024 at 10:15 AM Sebastian Wittmeier via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> Another more flexible variant could be a
>
> template<class T>
> std::forward_modified(Callable getter, Callable modifier);
>
>
> which would not construct the initial object by itself, but take the
> return value of another function as argument (with guaranteed RVO).
>
> return std::forward_modified(getmutex, lockit);
>
>
>
>
>
> -----Ursprüngliche Nachricht-----
> *Von:* Frederick Virchanza Gotham via Std-Proposals <
> std-proposals_at_[hidden]>
> *Gesendet:* Di 21.05.2024 00:00
> *Betreff:* Re: [std-proposals] std::elide
> *An:* std-proposals_at_[hidden];
> *CC:* Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>;
> On Mon, May 20, 2024 at 9:51 PM Sebastian Wittmeier via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
> >
> > This feature request could be also made to a standard library function.
> >
> > // Calls the constructor and a setup function. With guaranteed RVO.
> >
> > T std::factory<T>(params, ..., setup)
> >
> > No need for other language changes or any special exception handling.
>
>
> I've tried to implement it here:
>
> https://godbolt.org/z/v99dvGqnn
>
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
Received on 2024-05-21 15:04:27