This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] Make std::string default constructor conditionally noexcept
- From: Jonathan Wakely <jwakely at redhat dot com>
- To: libstdc++ at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Thu, 28 May 2015 13:33:43 +0100
- Subject: Re: [patch] Make std::string default constructor conditionally noexcept
- Authentication-results: sourceware.org; auth=none
- References: <20150513133629 dot GI30202 at redhat dot com>
On 13/05/15 14:36 +0100, Jonathan Wakely wrote:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4383.html#2455
Voted into the WP in Lenexa.
We already did the right thing for vector, so only basic_string needs
to change.
Tested powerpc64le-linux, committed to trunk.
Also committed to gcc-5-branch.
commit 634ed6e2d2ea4d69a29a8907044e6f68541d88aa
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed May 13 14:21:37 2015 +0100
* include/bits/basic_string.h (basic_string::basic_string()): Make
noexcept conditional on allocator (LWG 2455).
diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h
index 3e3eef4..093f502 100644
--- a/libstdc++-v3/include/bits/basic_string.h
+++ b/libstdc++-v3/include/bits/basic_string.h
@@ -377,7 +377,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
/**
* @brief Default constructor creates an empty string.
*/
- basic_string() _GLIBCXX_NOEXCEPT
+ basic_string()
+#if __cplusplus >= 201103L
+ noexcept(is_nothrow_default_constructible<_Alloc>::value)
+#endif
: _M_dataplus(_M_local_data())
{ _M_set_length(0); }