diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 187c59e99b48..1105afd01649 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,12 @@ +2016-10-10 Jonathan Wakely + + * include/bits/shared_ptr.h (enable_shared_from_this::weak_from_this): + Add noexcept. + * include/bits/shared_ptr_base.h + (__enable_shared_from_this::weak_from_this): Likewise. + * testsuite/20_util/enable_shared_from_this/members/weak_from_this.cc: + Test exception-specification of weak_from_this. + 2016-10-07 Jonathan Wakely * doc/xml/manual/status_cxx1998.xml: Improve documentation of diff --git a/libstdc++-v3/include/bits/shared_ptr.h b/libstdc++-v3/include/bits/shared_ptr.h index b2523b832286..cbcb3b3f3ca0 100644 --- a/libstdc++-v3/include/bits/shared_ptr.h +++ b/libstdc++-v3/include/bits/shared_ptr.h @@ -593,11 +593,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 #define __cpp_lib_enable_shared_from_this 201603 weak_ptr<_Tp> - weak_from_this() + weak_from_this() noexcept { return this->_M_weak_this; } weak_ptr - weak_from_this() const + weak_from_this() const noexcept { return this->_M_weak_this; } #endif diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h index 4ae26684dbe0..e8820a148c37 100644 --- a/libstdc++-v3/include/bits/shared_ptr_base.h +++ b/libstdc++-v3/include/bits/shared_ptr_base.h @@ -1562,11 +1562,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 __weak_ptr<_Tp, _Lp> - weak_from_this() + weak_from_this() noexcept { return this->_M_weak_this; } __weak_ptr - weak_from_this() const + weak_from_this() const noexcept { return this->_M_weak_this; } #endif diff --git a/libstdc++-v3/testsuite/20_util/enable_shared_from_this/members/weak_from_this.cc b/libstdc++-v3/testsuite/20_util/enable_shared_from_this/members/weak_from_this.cc index b5ebb81239cd..9c333966b3e2 100644 --- a/libstdc++-v3/testsuite/20_util/enable_shared_from_this/members/weak_from_this.cc +++ b/libstdc++-v3/testsuite/20_util/enable_shared_from_this/members/weak_from_this.cc @@ -26,6 +26,9 @@ struct X : public std::enable_shared_from_this { }; +static_assert( noexcept(std::declval().weak_from_this()) ); +static_assert( noexcept(std::declval().weak_from_this()) ); + void test01() {