C++ Logo

std-proposals

Advanced search

Re: [std-proposals] std::elide

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Tue, 21 May 2024 10:32:51 +0100
On Mon, May 20, 2024 at 10:59 PM Frederick Virchanza Gotham wrote:
>
> I've tried to implement it here:
>
> https://godbolt.org/z/v99dvGqnn


My previous implementation won't work with classes defined as 'final'.
I've made modifications, and here it is tested and working with GNU
g++, LLVM clang, Intel ICX and MSVC:

    https://msvc.godbolt.org/z/fEx71qK9K

The only drawback of this implementation is that it's not constexpr
because of the casts on Line #49 and #51 -- so perhaps it's worth
writing a paper to propose this new feature with the added note that
compiler support is required to make it constexpr?

So right now it looks as though there are three options on the table
to get NRVO in C++26:

   Option 1: Anton's paper P2025 (gathering dust for 3 years)
   Option 2: Get access to the "return slot", like this:
http://www.virjacode.com/papers/returnslot.htm
   Option 3: New standard library function std::factory<T,Params...,Setup>

Option No. 3 would be the least amount of grief and hassle for the
committee to write into the Standard and also for compiler vendors to
implement. Option 2 would give the absolute most freedom to do
whatever we want. Option No. 1 would probably be the best choice if we
disregarded the hassle.

So what will be? One, Two, or Three?

Received on 2024-05-21 09:33:07