Implement P0516: 'Clarify That shared_future’s Copy Operations have Wide Contracts' which was adopted last week in Issaquah
llvm-svn: 286877
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: 065b3af096c7171de33e774d29c4b9f2fd22821a
diff --git a/include/future b/include/future
index 656f9c7..ce22c1e 100644
--- a/include/future
+++ b/include/future
@@ -2374,7 +2374,7 @@
_LIBCPP_INLINE_VISIBILITY
shared_future() _NOEXCEPT : __state_(nullptr) {}
_LIBCPP_INLINE_VISIBILITY
- shared_future(const shared_future& __rhs) : __state_(__rhs.__state_)
+ shared_future(const shared_future& __rhs) _NOEXCEPT : __state_(__rhs.__state_)
{if (__state_) __state_->__add_shared();}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
@@ -2385,7 +2385,7 @@
{__rhs.__state_ = nullptr;}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
~shared_future();
- shared_future& operator=(const shared_future& __rhs);
+ shared_future& operator=(const shared_future& __rhs) _NOEXCEPT;
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
shared_future& operator=(shared_future&& __rhs) _NOEXCEPT
@@ -2429,7 +2429,7 @@
template <class _Rp>
shared_future<_Rp>&
-shared_future<_Rp>::operator=(const shared_future& __rhs)
+shared_future<_Rp>::operator=(const shared_future& __rhs) _NOEXCEPT
{
if (__rhs.__state_)
__rhs.__state_->__add_shared();
diff --git a/test/std/thread/futures/futures.shared_future/copy_assign.pass.cpp b/test/std/thread/futures/futures.shared_future/copy_assign.pass.cpp
index 3f9e945..abb9928 100644
--- a/test/std/thread/futures/futures.shared_future/copy_assign.pass.cpp
+++ b/test/std/thread/futures/futures.shared_future/copy_assign.pass.cpp
@@ -15,10 +15,13 @@
// class shared_future<R>
// shared_future& operator=(const shared_future& rhs);
+// noexcept in C++17
#include <future>
#include <cassert>
+#include "test_macros.h"
+
int main()
{
{
@@ -27,6 +30,9 @@
std::shared_future<T> f0 = p.get_future();
std::shared_future<T> f;
f = f0;
+#if TEST_STD_VER > 14
+ static_assert(noexcept(f = f0), "" );
+#endif
assert(f0.valid());
assert(f.valid());
}
diff --git a/test/std/thread/futures/futures.shared_future/copy_ctor.pass.cpp b/test/std/thread/futures/futures.shared_future/copy_ctor.pass.cpp
index 1da0880..2b66331 100644
--- a/test/std/thread/futures/futures.shared_future/copy_ctor.pass.cpp
+++ b/test/std/thread/futures/futures.shared_future/copy_ctor.pass.cpp
@@ -15,10 +15,13 @@
// class shared_future<R>
// shared_future(const shared_future& rhs);
+// noexcept in C++17
#include <future>
#include <cassert>
+#include "test_macros.h"
+
int main()
{
{
@@ -26,6 +29,9 @@
std::promise<T> p;
std::shared_future<T> f0 = p.get_future();
std::shared_future<T> f = f0;
+#if TEST_STD_VER > 14
+ static_assert(noexcept(std::shared_future<T>{f0}), "" );
+#endif
assert(f0.valid());
assert(f.valid());
}
diff --git a/www/cxx1z_status.html b/www/cxx1z_status.html
index f08127c..e998037 100644
--- a/www/cxx1z_status.html
+++ b/www/cxx1z_status.html
@@ -137,7 +137,7 @@
<tr><td><a href="http://wg21.link/P0509R1">P0509R1</a></td><td>LWG</td><td>Updating “Restrictions on exception handling”</td><td>Issaquah</td><td></td><td></td></tr>
<tr><td><a href="http://wg21.link/P0510R0">P0510R0</a></td><td>LWG</td><td>Disallowing references, incomplete types, arrays, and empty variants</td><td>Issaquah</td><td></td><td></td></tr>
<tr><td><a href="http://wg21.link/P0513R0">P0513R0</a></td><td>LWG</td><td>Poisoning the Hash</td><td>Issaquah</td><td></td><td></td></tr>
- <tr><td><a href="http://wg21.link/P0516R0">P0516R0</a></td><td>LWG</td><td>Clarify That shared_future’s Copy Operations have Wide Contracts</td><td>Issaquah</td><td></td><td></td></tr>
+ <tr><td><a href="http://wg21.link/P0516R0">P0516R0</a></td><td>LWG</td><td>Clarify That shared_future’s Copy Operations have Wide Contracts</td><td>Issaquah</td><td>Complete</td><td>4.0</td></tr>
<tr><td><a href="http://wg21.link/P0517R0">P0517R0</a></td><td>LWG</td><td>Make future_error Constructible</td><td>Issaquah</td><td>Complete</td><td>4.0</td></tr>
<tr><td><a href="http://wg21.link/P0521R0">P0521R0</a></td><td>LWG</td><td>Proposed Resolution for CA 14 (shared_ptr use_count/unique)</td><td>Issaquah</td><td></td><td></td></tr>