C++ Logo

std-proposals

Advanced search

Re: [std-proposals] std::elide

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Mon, 27 May 2024 21:56:54 +0100
On Mon, May 27, 2024 at 9:48 PM Lorand Szollosi wrote:
>
> void Func(T* t) /* here, *t is not yet constructed */
> {
> new(t) T();
> doSomethingWithT(t);
> }
>
> Then:
>
> template<typename R, typename... Params>
> consteval auto nrvo( void (*const arg)(R*, Params...) ) -> R(*)(Params...);
>
> Usage is the same. But then, it's very similar to std::factory.


Yeah that would work too. In fact, that's how compilers do it on 9 out
of 10 platforms, as described in this old paper:

    http://www.virjacode.com/papers/paper_nrvo_latest.pdf

But the reason I wanted to have "std::return_slot" instead of passing
a pointer as the first argument to the function, is that on 4
platforms, they don't pass the return slot in the first parameter.
Those 4 platforms are: 64-Bit ARM, HPPA, m68k, sh4. This is discussed
on Page 4 of the above paper.

If we were to have "std::return_slot" instead of putting the pointer
in the first parameter, it would accommodate those 4 platforms.

Received on 2024-05-27 20:57:07