Add noexcept to enable_shared_from_this::weak_from_this
authorJonathan Wakely <jwakely@redhat.com>
Mon, 10 Oct 2016 11:44:05 +0000 (12:44 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Mon, 10 Oct 2016 11:44:05 +0000 (12:44 +0100)
* 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.

From-SVN: r240917

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/shared_ptr.h
libstdc++-v3/include/bits/shared_ptr_base.h
libstdc++-v3/testsuite/20_util/enable_shared_from_this/members/weak_from_this.cc

index 187c59e99b4840b571d9600a6c02d8a988405ac3..1105afd01649098e067eee68ed3f9f56b0f03c16 100644 (file)
@@ -1,3 +1,12 @@
+2016-10-10  Jonathan Wakely  <jwakely@redhat.com>
+
+       * 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  <jwakely@redhat.com>
 
        * doc/xml/manual/status_cxx1998.xml: Improve documentation of
index b2523b832286bd393d571b12f8bf904be57a61ad..cbcb3b3f3ca0c84d81b12a55605f2ad6611abdf9 100644 (file)
@@ -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<const _Tp>
-      weak_from_this() const
+      weak_from_this() const noexcept
       { return this->_M_weak_this; }
 #endif
 
index 4ae26684dbe03b2b524373f6b16d5dd640cbe90a..e8820a148c3781892cf99678f1b8cc5ff4d2e724 100644 (file)
@@ -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<const _Tp, _Lp>
-      weak_from_this() const
+      weak_from_this() const noexcept
       { return this->_M_weak_this; }
 #endif
 
index b5ebb81239cdec2f9dab3ad6b41243048d1991b8..9c333966b3e257087b57ea96f2e6bbab6ed13060 100644 (file)
@@ -26,6 +26,9 @@
 
 struct X : public std::enable_shared_from_this<X> { };
 
+static_assert( noexcept(std::declval<X&>().weak_from_this()) );
+static_assert( noexcept(std::declval<const X&>().weak_from_this()) );
+
 void
 test01()
 {