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

Marc Mutz marc.mutz at kdab.com
Thu Jul 23 14:42:18 CEST 2015


On Thursday 08 January 2015 23:33:34 Thiago Macieira wrote:
>  * Q_DECL_NOTHROW / Q_DECL_NOEXCEPT - strongly encouraged
> 
> To public functions (all modules); any function in modules compiled with 
> exception (QtCore, QtXmlPatterns, QtConcurrent).
> 
> You probably want Q_DECL_NOTHROW instead of Q_DECL_NOEXCEPT.
> 
> Do not add to functions that:
>  * allocate memory
>  * call functions that may throw, especially user functions
>  * call POSIX cancellation points
>  * have narrow contracts -- that is, you could conceivably add a Q_ASSERT
> on  input parameters
> 
> If the function is an inline template function and the exception depends
> on  the template argument, use Q_DECL_NOEXCEPT_EXPR.

Consensus, I think?

I'd add that having a nothrow move ctor and move assignment operator is a very 
important optimisation for std::vector. User-defined copy ctors and copy 
assignment operators, but also a user-defined dtors (even if empty) inhibit 
the synthesising of move special member functions by the compiler, so remove 
them when you can or manually add the move special member functions, 
preferably with Q_DECL_NOTHROW / Q_DECL_NOEXCEPT_EXPR.

Example changes for both situations:

https://codereview.qt-project.org/121833
https://codereview.qt-project.org/121824

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