[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: Thiago Macieira <thiago () kde ! org>
Date: 2022-07-27 23:38:50
Message-ID: 7546046.lvqk35OSZv () tjmaciei-mobl5
[Download RAW message or body]
On Wednesday, 27 July 2022 14:37:20 PDT Friedrich W. H. Kossebau wrote:
> * new overload method (and any further ones) will stay special
> * existing consumer code using {} is not that simple to map by human readers
> as to which overload will be used
> * needs C++17, so needs some additional markup when used in KF5 headers for
> those using them with C++11-compat needs
You can use std::enable_if (no _t).
Another trick is what we do in Qt with Q_WEAK_OVERLOAD:
template <typename = void>
It doesn't matter what the parameters are and that this new template function
doesn't actually use the template parameter. As a template function, it will
not get selected for conversion; the types must match exactly.
This is handy even without {}, when you want to down-prioritise some overloads
over others for some reason, to avoid ambiguity. For example, you can't
overload a QByteArray with QLatin1String (or Qt6's QByteArrayView or
QAnyStringView or any such other combination) because it makes calling with a
character literal ambiguous. But you can if one of them is a weak overload.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel DPG Cloud Engineering
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic