C++ Logo

std-proposals

Advanced search

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

From: Egor <holyblckcat_at_[hidden]>
Date: Wed, 27 Dec 2023 10:39:14 +0600
25.12.2023 05:19, Edward Catmur пишет:
>
> 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).
>
>
> It seems to work; am I missing something? https://godbolt.org/z/3c5fjnqo4

`std::is_convertible_v<const U&, secret_base<T>>` and
`std::is_convertible_v<const U&, optional<T>>` are not equivalent. You
could have arbitrary constraints on `A::operator T` that permit
conversions to one and not the other.

Received on 2023-12-27 04:39:18