diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2015-09-11 12:02:14 +0100 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2015-09-11 12:02:14 +0100 |
commit | 5caff414f153f50aad00f1bc0d793776676e492b (patch) | |
tree | 7f874e1b19838f08d31b01a85708c48602ae8eb8 /libstdc++-v3/include/debug | |
parent | 997ed914e2c1ca4083affd78fd22569f5e734d08 (diff) | |
download | gcc-5caff414f153f50aad00f1bc0d793776676e492b.zip gcc-5caff414f153f50aad00f1bc0d793776676e492b.tar.gz gcc-5caff414f153f50aad00f1bc0d793776676e492b.tar.bz2 |
Implement N4258 noexcept for std::basic_string.
PR libstdc++/58265
* doc/xml/manual/intro.xml: Document LWG 2063 and 2064 resolutions.
* doc/html/manual/bugs.html: Regenerate.
* include/bits/basic_string.h (basic_string): Implement N4258. Add
correct exception-specifications and propagate allocators correctly.
* include/bits/basic_string.tcc (basic_string::swap): Propagate
allocators correctly.
* include/debug/string (__gnu_debug::basic_string): Add correct
exceptions-specifications and allcoator-extended constructors.
* testsuite/21_strings/basic_string/allocator/char/copy.cc: New.
* testsuite/21_strings/basic_string/allocator/char/copy_assign.cc:
New.
* testsuite/21_strings/basic_string/allocator/char/minimal.cc: New.
* testsuite/21_strings/basic_string/allocator/char/move.cc: New.
* testsuite/21_strings/basic_string/allocator/char/move_assign.cc:
New.
* testsuite/21_strings/basic_string/allocator/char/noexcept.cc: New.
* testsuite/21_strings/basic_string/allocator/char/swap.cc: New.
* testsuite/21_strings/basic_string/allocator/wchar_t/copy.cc: New.
* testsuite/21_strings/basic_string/allocator/wchar_t/copy_assign.cc:
New.
* testsuite/21_strings/basic_string/allocator/wchar_t/minimal.cc: New.
* testsuite/21_strings/basic_string/allocator/wchar_t/move.cc: New.
* testsuite/21_strings/basic_string/allocator/wchar_t/move_assign.cc:
New.
* testsuite/21_strings/basic_string/allocator/wchar_t/noexcept.cc: New.
* testsuite/21_strings/basic_string/allocator/wchar_t/swap.cc: New.
* testsuite/util/testsuite_allocator.h (tracker_allocator): Define
defaulted assignment operators.
From-SVN: r227681
Diffstat (limited to 'libstdc++-v3/include/debug')
-rw-r--r-- | libstdc++-v3/include/debug/string | 50 |
1 files changed, 34 insertions, 16 deletions
diff --git a/libstdc++-v3/include/debug/string b/libstdc++-v3/include/debug/string index 72ae88e..d1f4a56 100644 --- a/libstdc++-v3/include/debug/string +++ b/libstdc++-v3/include/debug/string @@ -36,19 +36,19 @@ namespace __gnu_debug { - /// Class std::basic_string with safety/checking/debug instrumentation. - template<typename _CharT, typename _Traits = std::char_traits<_CharT>, - typename _Allocator = std::allocator<_CharT> > - class basic_string - : public __gnu_debug::_Safe_container< - basic_string<_CharT, _Traits, _Allocator>, - _Allocator, _Safe_sequence, bool(_GLIBCXX_USE_CXX11_ABI)>, - public std::basic_string<_CharT, _Traits, _Allocator> - { - typedef std::basic_string<_CharT, _Traits, _Allocator> _Base; - typedef __gnu_debug::_Safe_container< - basic_string, _Allocator, _Safe_sequence, bool(_GLIBCXX_USE_CXX11_ABI)> - _Safe; +/// Class std::basic_string with safety/checking/debug instrumentation. +template<typename _CharT, typename _Traits = std::char_traits<_CharT>, + typename _Allocator = std::allocator<_CharT> > + class basic_string + : public __gnu_debug::_Safe_container< + basic_string<_CharT, _Traits, _Allocator>, + _Allocator, _Safe_sequence, bool(_GLIBCXX_USE_CXX11_ABI)>, + public std::basic_string<_CharT, _Traits, _Allocator> + { + typedef std::basic_string<_CharT, _Traits, _Allocator> _Base; + typedef __gnu_debug::_Safe_container< + basic_string, _Allocator, _Safe_sequence, bool(_GLIBCXX_USE_CXX11_ABI)> + _Safe; public: // types: @@ -72,9 +72,13 @@ namespace __gnu_debug using _Base::npos; + basic_string() + _GLIBCXX_NOEXCEPT_IF(std::is_nothrow_default_constructible<_Base>::value) + : _Base() { } + // 21.3.1 construct/copy/destroy: - explicit basic_string(const _Allocator& __a = _Allocator()) - // _GLIBCXX_NOEXCEPT + explicit + basic_string(const _Allocator& __a) _GLIBCXX_NOEXCEPT : _Base(__a) { } #if __cplusplus < 201103L @@ -91,7 +95,19 @@ namespace __gnu_debug : _Base(__l, __a) { } +#if _GLIBCXX_USE_CXX11_ABI + basic_string(const basic_string& __s, const _Allocator& __a) + : _Base(__s, __a) { } + + basic_string(basic_string&& __s, const _Allocator& __a) + : _Base(std::move(__s), __a) { } +#endif + ~basic_string() = default; + + // Provides conversion from a normal-mode string to a debug-mode string + basic_string(_Base&& __base) noexcept + : _Base(std::move(__base)) { } #endif // C++11 // Provides conversion from a normal-mode string to a debug-mode string @@ -278,7 +294,7 @@ namespace __gnu_debug reference operator[](size_type __pos) // _GLIBCXX_NOEXCEPT { -#ifdef _GLIBCXX_DEBUG_PEDANTIC +#if __cplusplus < 201103L && defined(_GLIBCXX_DEBUG_PEDANTIC) __glibcxx_check_subscript(__pos); #else // as an extension v3 allows s[s.size()] when s is non-const. @@ -413,6 +429,7 @@ namespace __gnu_debug #if __cplusplus >= 201103L basic_string& assign(basic_string&& __x) + noexcept(noexcept(std::declval<_Base&>().assign(std::move(__x)))) { _Base::assign(std::move(__x)); this->_M_invalidate_all(); @@ -729,6 +746,7 @@ namespace __gnu_debug void swap(basic_string& __x) + _GLIBCXX_NOEXCEPT_IF(std::__is_nothrow_swappable<_Base>::value) { _Safe::_M_swap(__x); _Base::swap(__x); |