[Development] Upgrading the sources to C++11 keywords (Q_NULLPTR, etc.)

Konstantin Tokarev annulen at yandex.ru
Wed Feb 11 10:30:00 CET 2015



11.02.2015, 12:13, "Marc Mutz" <marc.mutz at kdab.com>:
> On Wednesday 11 February 2015 00:37:18 Matthew Woehlke wrote:
>>  Marc, I'm not sure if you're arguing for or against nullptr :-)...
>
> Then I agree with André; you need to start reading mails (threads) before
> responding :)
>>  On 2015-02-10 18:23, Marc Mutz wrote:
>>>  On Tuesday 10 February 2015 20:13:12 André Pönitz wrote:
>>>>  Can't you simply wait until 'nullptr' is available?
>>>  No.
>>>
>>>  For a simple reason: using nullptr (Q_ or not) is more expressive than 0.
>>>  And why would i want to throw away information I already have?
>>  (Oh... and 'auto ptr = 0;' does not give you a pointer. Not relevant to
>>  Qt, but just saying...)
>
> While true, this is semantics that we can't rely on in Qt atm. Neither can
> auto be used, nor can it be relied on that Q_NULLPTR doesn't convert to an
> integral type. The latter is esp. interesting, as I believe some compilers
> implement NULL to be nullptr-like even in C++98 (and Q_NULLPTR is NULL if it's
> not nullptr), so you *may* benefit even in C++98 by using Q_NULLPTR instead of
> 0. But you can't _rely_ on that.

One can just use NULL and get the best of both worlds - C++98 compatibility and
warnings about type conversions.

-- 
Regards,
Konstantin



More information about the Development mailing list