[Development] Proposal: adding Q_DECL_NOEXCEPT to many methods

Thiago Macieira thiago.macieira at intel.com
Thu Aug 2 22:11:42 CEST 2012


On quinta-feira, 2 de agosto de 2012 19.25.31, marius.storm-olsen at nokia.com 
wrote:
> Anyways, I see that LLVM/libc++ 
> (http://llvm.org/svn/llvm-project/libcxx/trunk/include/__config) defines 
> it like this:
>    #if (__has_feature(cxx_noexcept))
>    #  define _NOEXCEPT noexcept
>    #  define _NOEXCEPT_(x) noexcept(x)
>    #else
>    #  define _NOEXCEPT throw()
>    #  define _NOEXCEPT_(x)
>    #endif
> so, they do what I suggested, except they use 'noexcept' instead of 
> 'noexcept(true)'. (Shouldn't really matter, just that the latter is more 
> clear, IMO.)

This is GCC:

#ifndef _GLIBCXX_NOTHROW
# ifndef __cplusplus
#  define _GLIBCXX_NOTHROW __attribute__((__nothrow__))
# endif
#endif

#ifndef _GLIBCXX_NOEXCEPT
# ifdef __GXX_EXPERIMENTAL_CXX0X__
#  define _GLIBCXX_NOEXCEPT noexcept
#  define _GLIBCXX_USE_NOEXCEPT noexcept
#  define _GLIBCXX_THROW(_EXC)
# else
#  define _GLIBCXX_NOEXCEPT
#  define _GLIBCXX_USE_NOEXCEPT throw()
#  define _GLIBCXX_THROW(_EXC) throw(_EXC)
# endif
#endif

#ifndef _GLIBCXX_NOTHROW
# define _GLIBCXX_NOTHROW _GLIBCXX_USE_NOEXCEPT
#endif

There are three macros: NOEXCEPT, USE_NOEXCEPT and NOTHROW:

$ grep -r _GLIBCXX_NOTHROW *~x86_64-redhat-linux | wc -l
13
$ grep -r _GLIBCXX_NOEXCEPT *~x86_64-redhat-linux | wc -l
607
$ grep -r _GLIBCXX_USE_NOEXCEPT *~x86_64-redhat-linux | wc -l
264

Don't ask me why they need three. But two of them expand to noexcept or empty, 
only USE_NOEXCEPT expands to throw() in C++98 code.

The NO_THROW ones are used only in C functions (the __cxa_foo ones). And I 
think the USE_NOEXCEPT one is used only where the C++98 standard required it.
-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
     Intel Sweden AB - Registration Number: 556189-6027
     Knarrarnäsgatan 15, 164 40 Kista, Stockholm, Sweden
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/development/attachments/20120802/b2080bc7/attachment.sig>


More information about the Development mailing list