This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[patch] Add noexcept to default constructors of std::map, std::set etc.
- 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: Fri, 26 Jun 2015 17:45:53 +0100
- Subject: [patch] Add noexcept to default constructors of std::map, std::set etc.
- Authentication-results: sourceware.org; auth=none
Howard pointed out that we're missing some noexcept guarantees on the
default constructors of RB trees, where libc++ has them.
Up with this I will not put.
I'm committing this to trunk and gcc-5-branch, tested
powerpc64le-linux.
commit 56134d0ab24c603ed62fdff199008ac55804d61a
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Fri Jun 26 02:00:00 2015 +0100
* include/bits/stl_bvector.h (vector<bool>::vector()): Add noexcept.
* include/bits/stl_map.h (map::map()): Likewise.
* include/bits/stl_multimap.h (multimap::multimap()): Likewise.
* include/bits/stl_multiset.h (multiset::multiset()): Likewise.
* include/bits/stl_set.h (set::set()): Likewise.
diff --git a/libstdc++-v3/include/bits/stl_bvector.h b/libstdc++-v3/include/bits/stl_bvector.h
index 7b93d95..71bee21 100644
--- a/libstdc++-v3/include/bits/stl_bvector.h
+++ b/libstdc++-v3/include/bits/stl_bvector.h
@@ -573,6 +573,9 @@ template<typename _Alloc>
public:
vector()
+#if __cplusplus >= 201103L
+ noexcept(is_nothrow_default_constructible<allocator_type>::value)
+#endif
: _Base() { }
explicit
diff --git a/libstdc++-v3/include/bits/stl_map.h b/libstdc++-v3/include/bits/stl_map.h
index df18973..179e3f2 100644
--- a/libstdc++-v3/include/bits/stl_map.h
+++ b/libstdc++-v3/include/bits/stl_map.h
@@ -160,6 +160,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* @brief Default constructor creates no elements.
*/
map()
+#if __cplusplus >= 201103L
+ noexcept(is_nothrow_default_constructible<allocator_type>::value)
+#endif
: _M_t() { }
/**
diff --git a/libstdc++-v3/include/bits/stl_multimap.h b/libstdc++-v3/include/bits/stl_multimap.h
index f3d21ab..10ac0fa 100644
--- a/libstdc++-v3/include/bits/stl_multimap.h
+++ b/libstdc++-v3/include/bits/stl_multimap.h
@@ -158,6 +158,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* @brief Default constructor creates no elements.
*/
multimap()
+#if __cplusplus >= 201103L
+ noexcept(is_nothrow_default_constructible<allocator_type>::value)
+#endif
: _M_t() { }
/**
diff --git a/libstdc++-v3/include/bits/stl_multiset.h b/libstdc++-v3/include/bits/stl_multiset.h
index 7e92836..0a476d1 100644
--- a/libstdc++-v3/include/bits/stl_multiset.h
+++ b/libstdc++-v3/include/bits/stl_multiset.h
@@ -138,6 +138,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* @brief Default constructor creates no elements.
*/
multiset()
+#if __cplusplus >= 201103L
+ noexcept(is_nothrow_default_constructible<allocator_type>::value)
+#endif
: _M_t() { }
/**
diff --git a/libstdc++-v3/include/bits/stl_set.h b/libstdc++-v3/include/bits/stl_set.h
index 5189234..2e5c89f 100644
--- a/libstdc++-v3/include/bits/stl_set.h
+++ b/libstdc++-v3/include/bits/stl_set.h
@@ -140,6 +140,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* @brief Default constructor creates no elements.
*/
set()
+#if __cplusplus >= 201103L
+ noexcept(is_nothrow_default_constructible<allocator_type>::value)
+#endif
: _M_t() { }
/**