[Development] Ideas for adding an argument with default value to a virtual method
Stephen Kelly
stephen.kelly at kdab.com
Tue Jan 24 23:41:18 CET 2012
On Tuesday, January 24, 2012 20:36:53 Thiago Macieira wrote:
> On Tuesday, 24 de January de 2012 22.45.54, Stephen Kelly wrote:
> > 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).
>
> Change the return value of the method that you don't want overridden to
> something completely different.
>
> You cannot override a method with a non-covariant return type, so that will
> cause a compiler error and point to the change.
Yes, that's one of the things I tried:
On Tuesday, January 24, 2012 22:45:54 Stephen Kelly wrote:
> , 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 would have to actually add new virtual methods with a new name instead of
changing the parameters (and then call the old implementation from the old one
- which would mean not deprecating the old one).
I'm not sure that's worth it. I also can't think of a more elegant solution,
so I may just have to give up on it.
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/5ad889ba/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/development/attachments/20120124/5ad889ba/attachment.sig>
More information about the Development
mailing list