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, 5 Sep 2023 08:37:09 +0100
On Sun, Sep 3, 2023 at 8:22 PM Frederick Virchanza Gotham wrote:
>
> Something like:
>
> struct Monkey final {
> operator mutex(void) priority
> {
> // our code in here returns a mutex
> }
> };
>
> If a conversion operator is marked as 'priority' then in the following
> circumstance:
>
> ::new(p) T( Monkey() );
>
> Even if T has a template constructor that could accept an object of
> type 'Monkey', the compiler instead will search inside the class
> 'Monkey' for a conversion operator marked 'priority', and if found,
> will invoke it. Two rules for marking a conversion operator as
> 'priority':
> (Rule 1) A class definition shall contain at most one conversion
> operator marked as 'priority'.
> (Rule 2) Only a class marked as 'final' may contain a conversion
> operator marked as 'priority'.


Anyone wanna take a bite out of this?

What we're trying to do is figure out a way of using
std::optional::emplace to put the unmovable-and-uncopiable return
value of a function inside an std::optional (or 'variant' or 'any').

Received on 2023-09-05 07:37:24