Challenge: adding new method overloads when existing consumers use {} with args

David Hurka david.hurka at mailbox.org
Sat Jul 23 19:26:47 BST 2022


> 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.




More information about the kde-devel mailing list