C++ Logo


Advanced search

Re: [std-proposals] Making the converting constructor of std::optional less greedy

From: Egor <holyblckcat_at_[hidden]>
Date: Wed, 20 Dec 2023 14:55:09 +0600
19.12.2023 07:07, Edward Catmur пишет:
> On Sat, 9 Dec 2023 at 01:13, Egor via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
> 07.12.2023 11:15, Egor пишет:
> After thinking about it, I'm not sure this is even implementable
> in the
> first place. This constraint would have to be self-referential, and I
> think those are illegal.
> It's quite easy, actually; all you have to do is test for
> convertibility to an arbitrary hypothetical unambiguous public base
> class of the class being constructed. This should be implementable
> without affecting ABI, I think.
This won't always work. If the conversion operator is templated, it will
receive the base class type, not the derived type, and the behavior for
the two can be different (one of them can be rejected by SFINAE but not
the other, etc).

Received on 2023-12-20 08:55:15