[Development] Ideas for adding an argument with default value to a virtual method
Stephen Kelly
stephen.kelly at kdab.com
Tue Jan 24 22:45:54 CET 2012
Hi,
https://bugreports.qt.nokia.com/browse/QTBUG-1072
This bug is essentially a request to change the QAIM API:
virtual void fetchMore(const QModelIndex &parent);
virtual bool canFetchMore(const QModelIndex &parent) const;
into:
virtual void fetchMore(const QModelIndex &parent, Qt::Orientation
orientation = Qt::UnspecifiedOrientation);
virtual bool canFetchMore(const QModelIndex &parent, Qt::Orientation
orientation = Qt::UnspecifiedOrientation) const;
(A new enum value of UnspecifiedOrientation would also be needed)
I think it makes sense, but that is an often used and overridden virtual
method, and changing it would not make the compiler notify about the porting
need (Can't expect downstream to be using Q_DECL_OVERRIDE already).
I tried various other tricks like Q_DECL_FINAL to prevent overriding the wrong
signature (success - clang trunk gave an error for the derivation before
porting) Q_DECL_EQ_DELETE to delete the old method signature (failure - clang
trunk compiled with no error. Understandable), and changing the return type
(success - clang gives an error for the derivation before porting).
In the cases where an error is given for the deriving code (before porting),
calling code still can't compile because the call is ambiguous anyway.
I had an interesting play with new C++ keywords, but is there any elegant
solution to all this?
Thanks,
--
Stephen Kelly <stephen.kelly at kdab.com> | Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
www.kdab.com || Germany +49-30-521325470 || Sweden (HQ) +46-563-540090
KDAB - Qt Experts - Platform-Independent Software Solutions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20120124/e88ae804/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3636 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20120124/e88ae804/attachment.bin>
More information about the Development
mailing list