]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Add noexcept to some std::promise shared state internals
authorJonathan Wakely <jwakely@redhat.com>
Tue, 18 Jun 2024 19:59:25 +0000 (20:59 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Wed, 19 Jun 2024 16:34:19 +0000 (17:34 +0100)
Making the state ready for a std::promise<void> only needs to move a
unique_ptr, which cannot throw. Make its call operator noexcept.
Similarly, making the state ready by storing an exception_ptr also can't
throw, so make that call operator noexcept too.

libstdc++-v3/ChangeLog:

* include/std/future (_State_baseV2::_Setter<R, void>): Add
noexcept to call operator.
(_State_baseV2::_Setter<R, __exception_ptr_tag>): Likewise.

libstdc++-v3/include/std/future

index 9e75ae98b13d2b0cc10f48f2531b3beae6958c76..d7be205af506189d52cb6fc6fae939d358d567b1 100644 (file)
@@ -532,7 +532,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        {
          static_assert(is_void<_Res>::value, "Only used for promise<void>");
 
-         typename promise<_Res>::_Ptr_type operator()() const
+         typename promise<_Res>::_Ptr_type operator()() const noexcept
          { return std::move(_M_promise->_M_storage); }
 
          promise<_Res>*    _M_promise;
@@ -545,7 +545,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
         struct _Setter<_Res, __exception_ptr_tag>
         {
          // Used by std::promise to store an exception as the result.
-          typename promise<_Res>::_Ptr_type operator()() const
+          typename promise<_Res>::_Ptr_type operator()() const noexcept
           {
             _M_promise->_M_storage->_M_error = *_M_ex;
             return std::move(_M_promise->_M_storage);