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: Tue, 12 Sep 2023 14:22:20 +0100
On Mon, Sep 11, 2023 at 2:45 PM Frederick Virchanza Gotham wrote:
>
> So we already looked at two possibilities:
> (1) Mark the conversion operator
> (2) Mark the class
>
> The third possibility would be to have a base class that favours conversion:
>
> class Monkey : public std::priority_conversion< std::mutex >


Guys we have a very obvious deficit in the C++ programming language
here . . . we should be able to 'emplace' an
unmovable-and-uncopiable return value into an 'std::optional' /
'std::variant' / 'std::any' variable. That is to say we should be able
to do:

    optional<mutex> om;

    om.emplace( SomeFunctionThatReturnsMutex() );

Currently we can't do this, and it's something that needs to change.
So can people please give their opinions on which of the 3 proposed
solutions is preferable?
(1) Mark the conversion operator
(2) Mark the class
(3) Derive the class from 'std::priority_conversion'

Received on 2023-09-12 13:22:33