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

Giuseppe D'Angelo giuseppe.dangelo at kdab.com
Sat Jul 30 15:08:58 CEST 2022


On 30/07/2022 14:13, A. Pönitz wrote:
>> Ultimately, I think that we simply don't "really" deal with this particular
>> problem, and may accept the SIC. For instance, if we add a QStringView
>> overload to a function taking QString, this is a SIC but I don't think we
>> would reject the addition. I certainly don't think we should do super-clever
>> stuff. (E.g.: QLabel has these two constructors:
>>> QLabel(const QString &text, QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags())
>>>   QLabel(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags())
>> However:
>>>   QLabel *label = new QLabel({}); // compiles!
> This is a context that in my book clearly does not justify source
> incompatibility: This code typically run once per dialog/whatever
> instantation, waiting for further user interaction.
> A copy of the string contents with a few dozen or even hundreds of
> characters is completely acceptable under such circumstances.

I was just pointing out that QLabel({}) actually is well-formed and not 
ambiguous. This isn't evident at all if you look at the overloads; it 
has to do with subtleties in overload resolution. I was just claiming 
that we shouldn't exploit those subtleties too much in an attempt to 
avoid a SIC at all costs.

My 2 c,
Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - The Qt, C++ and OpenGL Experts
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4244 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.qt-project.org/pipermail/development/attachments/20220730/b151f188/attachment.bin>

More information about the Development mailing list