[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: Challenge: adding new method overloads when existing consumers use {} with args
From: David Hurka <david.hurka () mailbox ! org>
Date: 2022-07-23 18:31:20
Message-ID: 1831320.tdWV9SEqCh () doro
[Download RAW message or body]
On Saturday, July 23, 2022 8:26:47 PM CEST David Hurka wrote:
> > Had not yet thought about this challenge myself before, so curious what
> > people think can be done here?
>
> Would it work to make foo(B) less tasty for implicit conversion with
> std::variant (or another small wrapper)?
>
> ```
> class C
> {
> public:
> void foo(A a);
> /** @since ... */
> void foo(std::variant<B> b);
> };
> ```
>
> My assumption is that std::variant requires a "user-defined conversion" [1],
> and therefore an explicitly provided B object can be implicitly converted
> to a std::variant<B>, but the ambiguous {} can't.
[1] https://en.cppreference.com/w/cpp/language/implicit_conversion#Order_of_the_conversions
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic