C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Copy-construct, move-construct, and PR-construct

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Fri, 8 Sep 2023 09:11:30 +0100
I reply to Thiago and Jason in series below.


On Thu, Sep 7, 2023 at 10:57 PM Thiago Macieira via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> The uninitialised storage for an unmovable return type
> is passed as an implicit first parameter in any ABI.


Not for: 64-Bit ARM, SuperH, Motorolla 6800, HPPA. I had to write
separate assembler for them:
http://www.virjacode.com/downloads/nrvo/paper_nrvo_latest.pdf


Jason McKesson wrote:
>
> But that now requires `some_func` to know about how the object it
> creates is being stored. It needs to know if you're using an
> `optional<T>` or a `vector<T>` or something else. And it has to work
> with different emplacement APIs, like `emplace_back` vs. `emplace`.


And so in order to be generic about all of this -- When the compiler encounters:

    ::new(p) T( forward<Params>(args)... );

We want it to invoke a conversion operator before passing an argument
to a constructor. My suggestion was to mark the conversion operator as
'priority', something like;

    class Monkey {
        operator mutex(void) priority
        {
            // return a mutex from in here
        }
    };

Another option would be to mark the class itself, maybe something like:

    class Monkey >> mutex {
        operator mutex(void)
        {
            // return a mutex from in here
        }
    };

Received on 2023-09-08 08:11:44