Hi, in 5.7, nullptr (Q_C_NULLPTR) is required to be supported by the compiler, but there are no guidelines as to its use in the coding conventions (to the extent they need to be in there).
I propose the following, based on Thiago's proposal from January this year, considering the new situation that we now require nullptr support in the compiler: - 0 as a nullptr constant is banned except in tests testing APIs so we don't accidentally require nullptr (ie. all tests should use 0, not nullptr, as far as it makes sense) - clang-modernize is used to convert all uses of the null pointer constant to nullptr, incl. examples, excl. tests and 3rdparty - compilers that have it, will have -Wzero-as-nullptr-constant added during headersclean[0] - APIs that require the use of nullptr for disambiguation are discouraged, but may be acceptable to be decided on a case-by-case basis. - Accidental (ie. non-apidox'ed) reliance on nullptr for disambiguation is always an error. To this end, tests should continue to use 0, not nullptr. - if (!foo) vs. if (foo == nullptr), if (foo) vs. if (foo != nullptr): author's prerogative[1] [0] I'd prefer "when building Qt", but realise that we'll have problems with upstream libs [1] I prefer the short form, but I don't think we'll gain a consensus here, so let's not even try Arguments in favour: - it's the C++ way of writing the null pointer constant these days - we need to use it in headers, anyway, to allow people to use -Wzero-as..., and it makes no sense to have two sets of rules for headers and impl - it can disambiguate code and prevent accidents - in some situations, it makes code easier to understand (: m_foo(nullptr)). Arguments against: - it's uglier than "0", and more to type Let's have comments and additions float in for a week, and then let's have Lars decide. Thanks, Marc -- Marc Mutz <[email protected]> | Senior Software Engineer KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company Tel: +49-30-521325470 KDAB - The Qt Experts _______________________________________________ Development mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/development
