public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Add noexcept to enable_shared_from_this::weak_from_this
@ 2016-10-10 11:43 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2016-10-10 11:43 UTC (permalink / raw)
  To: libstdc++, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 400 bytes --]

I missed out the "noexcept" on these new functions.

	* 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.

Tested powerpc64le-linux, committing to trunk.


[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 2437 bytes --]

commit 3f386e54098cb01df83a131ed4a8e22c0b0b52bd
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Mon Oct 10 11:42:00 2016 +0100

    Add noexcept to enable_shared_from_this::weak_from_this
    
    	* 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.

diff --git a/libstdc++-v3/include/bits/shared_ptr.h b/libstdc++-v3/include/bits/shared_ptr.h
index b2523b8..cbcb3b3 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<const _Tp>
-      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 4ae2668..e8820a1 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<const _Tp, _Lp>
-      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 b5ebb81..9c33396 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<X> { };
 
+static_assert( noexcept(std::declval<X&>().weak_from_this()) );
+static_assert( noexcept(std::declval<const X&>().weak_from_this()) );
+
 void
 test01()
 {

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-10-10 11:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-10 11:43 [PATCH] Add noexcept to enable_shared_from_this::weak_from_this Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).