[Development] Upgrading the sources to C++11 keywords (Q_NULLPTR, etc.)
Marc Mutz
marc.mutz at kdab.com
Thu Jul 23 14:23:33 CEST 2015
On Thursday 08 January 2015 23:33:34 Thiago Macieira wrote:
> * Q_NULLPTR - strongly encouraged
Ok, trying to summarize the discussion so we can move forward.
There's a bug report (https://bugreports.qt.io/browse/QTBUG-45291) about Qt
headers not compiling with -Wzero-as-null-pointer-constant, sometimes not even
when locking the Qt headers away behind an -isystem. I understood the
discussion in this thread as follows:
- ok to use Q_NULLPTR in public headers (the bug report suggests that this
should actually be enforced by headersclean).
- ok to use in new code or as a drive-by iff the 0 isn't immediately visible
as a nullptr. Example:
validator(0), // Q_NULLPTR ok here
Counter-example:
const char *msg = 0 // Q_NULLPTR not wanted here
- otherwise, we don't want Q_NULLPTR. We're waiting until we can move directly
to nullptr. In particular, we cannot use Q_NULLPTR for its potentially
disambiguating characteristics, until we require C++11 nullptr. So code must
still compile (modulo warnings) (and have the same meaning) if the Q_NULLPTR
is replaced back to 0.
Consensus?
Thanks,
Marc
--
Marc Mutz <marc.mutz at kdab.com> | Senior Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
Tel: +49-30-521325470
KDAB - The Qt Experts
More information about the Development
mailing list