[Interest] Future of constexpr in Qt?
Schimkowitsch Robert
Robert.Schimkowitsch at andritz.com
Fri Nov 22 08:14:30 CET 2024
Hi Volker,
do you think that the language (let's say up to 23, because constexpr could be a conditional macro anyway) would even allow making constexpr useful, bigger portions such as
- basic implicit sharing mechanism
- basic usage of QString
- basic usage of QList?
These are so common in our codebase that without them, only a relatively few functions can ever be made constexpr.
Herb Sutter highlighted constexpr as a way to increase programming language safety in his recent keynote at Meeting C++. Things like making a runtime function constexpr, so you can, at compile time, check for UB using static_asserts or such when feeding it with various ranges of values (min, max, zero, empty list,...). Now I'm thinking about how we could apply those ideas in real code - and Qt mostly stops us from doing that, right there and then.
Kind regards
Robert
-----Original Message-----
From: Volker Hilsheimer <volker.hilsheimer at qt.io>
Sent: Thursday, 21 November 2024 17:42
To: Schimkowitsch Robert <Robert.Schimkowitsch at andritz.com>
Cc: interest at qt-project.org
Subject: Re: [Interest] Future of constexpr in Qt?
CAUTION: External email. Do not click on links or open attachments unless you know the sender and that the content is safe.
> On 21 Nov 2024, at 10:55, Schimkowitsch Robert <Robert.Schimkowitsch at andritz.com> wrote:
>
> I’d like to use constexpr more in the future in order to catch UB in compile-time tests of functions.
> Qt has a little constexpr sprinkled here and there, but not a lot. Does anyone know if there are plans to expand Qt in this direction?
> Kind regards
> Robert
Hi Robert,
It’s generally not an item on the roadmap to make constexpr everything that can be. But when we touch code with expressions that could be constexpr, then we might make that change as a drive-by, if the code would otherwise benefit from it.
If there’s any part of Qt where you’d see significant value from making things constexpr, then you’re welcome to push things for review.
Cheers,
Volker
________________________________
This message and any attachments are solely for the use of the intended recipients. They may contain privileged and/or confidential information or other information protected from disclosure. If you are not an intended recipient, you are hereby notified that you received this email in error and that any review, dissemination, distribution or copying of this email and any attachment is strictly prohibited. If you have received this email in error, please contact the sender and delete the message and any attachment from your system.
ANDRITZ HYDRO GmbH
Rechtsform/ Legal form: Gesellschaft mit beschränkter Haftung / Corporation
Firmensitz/ Registered seat: Wien
Firmenbuchgericht/ Court of registry: Handelsgericht Wien
Firmenbuchnummer/ Company registration: FN 61833 g
DVR: 0605077
UID-Nr.: ATU14756806
Thank You
________________________________
More information about the Interest
mailing list