diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2021-12-02 11:53:21 +0000 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2021-12-02 16:53:13 +0000 |
commit | acf4fe96f12341da253fa9a932947581690122a4 (patch) | |
tree | 6c2d5451325ac05788edbd12aaf06bf8b39e588f | |
parent | e2e98f524fdb80c16e3395f20fee930fbcad5562 (diff) | |
download | gcc-acf4fe96f12341da253fa9a932947581690122a4.zip gcc-acf4fe96f12341da253fa9a932947581690122a4.tar.gz gcc-acf4fe96f12341da253fa9a932947581690122a4.tar.bz2 |
libstdc++: Allow exception classes to move fully-dynamic strings
The move constructor for the fully-dynamic std::basic_string was not
noexcept until recently, so the std::logic_error and std::runtime_error
move constructors were defined to make non-throwing copies of their
string members, instead of potentially-throwing moves.
Now that move construction is always noexecpt, the exception classes can
always move the string. The fully-dynamic string move assignment was
always noexcept, so I don't know why I special-cased the move assignment
operators of the exception classes. That can be changed too.
libstdc++-v3/ChangeLog:
* src/c++11/cow-stdexcept.cc [_GLIBCXX_FULY_DYNAMIC_STRING]
(logic_error, runtime_error): Remove custom definitions.
-rw-r--r-- | libstdc++-v3/src/c++11/cow-stdexcept.cc | 20 |
1 files changed, 0 insertions, 20 deletions
diff --git a/libstdc++-v3/src/c++11/cow-stdexcept.cc b/libstdc++-v3/src/c++11/cow-stdexcept.cc index 751c330..2d47acb 100644 --- a/libstdc++-v3/src/c++11/cow-stdexcept.cc +++ b/libstdc++-v3/src/c++11/cow-stdexcept.cc @@ -57,8 +57,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // These operations are noexcept even though copying a COW string is not, // but we know that the string member in an exception has not been "leaked" // so copying is a simple reference count increment. - // For the fully dynamic string moves are not noexcept (due to needing to - // allocate an empty string) so we just define the moves as copies here. logic_error::logic_error(const logic_error& e) noexcept : exception(e), _M_msg(e._M_msg) { } @@ -66,19 +64,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION logic_error& logic_error::operator=(const logic_error& e) noexcept { _M_msg = e._M_msg; return *this; } -#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 logic_error::logic_error(logic_error&& e) noexcept = default; logic_error& logic_error::operator=(logic_error&& e) noexcept = default; -#else - logic_error::logic_error(logic_error&& e) noexcept - : exception(e), _M_msg(e._M_msg) { } - - logic_error& - logic_error::operator=(logic_error&& e) noexcept - { _M_msg = e._M_msg; return *this; } -#endif runtime_error::runtime_error(const runtime_error& e) noexcept : exception(e), _M_msg(e._M_msg) { } @@ -87,19 +76,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION runtime_error::operator=(const runtime_error& e) noexcept { _M_msg = e._M_msg; return *this; } -#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 runtime_error::runtime_error(runtime_error&& e) noexcept = default; runtime_error& runtime_error::operator=(runtime_error&& e) noexcept = default; -#else - runtime_error::runtime_error(runtime_error&& e) noexcept - : exception(e), _M_msg(e._M_msg) { } - - runtime_error& - runtime_error::operator=(runtime_error&& e) noexcept - { _M_msg = e._M_msg; return *this; } -#endif // New C++11 constructors: |