[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: Re: Use of const arg in KConfigGroup constructors doesn't work with
From: Thiago Macieira <thiago () kde ! org>
Date: 2008-03-05 9:02:29
Message-ID: 200803051002.36627.thiago () kde ! org
[Download RAW message or body]
On Wednesday 05 March 2008 09:02:49 Lubos Lunak wrote:
> No. In fact it is less clear and more error prone. Using 'const' is a
> normal C++ way and it lets the language to handle constness automatically.
> The code you posted will not work (compile) if the KConfigBase is already
> const and it forces the developer to do manually what the compiler can do
> on its own (and the compiler is not human, so unlike the developer it
> should not do mistakes :) ). It is rather common to overload methods in C++
> based on constness and I'm surprised this is the first time you've run into
> it.
I'd say that we should have both things:
KConfigGroup(KConfigBase *master, const QString &group, AccessType mode =
ReadOnly);
KConfigGroup(const KConfigBase *master, const QString &group);
i.e., the second form is enforced read-only, whereas the first can be
selected. For instance, I could have a read-write KConfigBase * that I wanted
to create a read-only form from. Casting it into const seems bizarre to me.
In order to maintain binary compatibility, we can't have the first form, but
we have to introduce a third with a non-default argument. And add a ### KDE 5
marker.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
["signature.asc" (application/pgp-signature)]
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic