[gcc r15-1451] libstdc++: Add noexcept to some std::promise shared state internals

Jonathan Wakely redi@gcc.gnu.org
Wed Jun 19 16:35:37 GMT 2024


https://gcc.gnu.org/g:5d156a91853a7863d674ed35df87562e3a1eba0e

commit r15-1451-g5d156a91853a7863d674ed35df87562e3a1eba0e
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Jun 18 20:59:25 2024 +0100

    libstdc++: Add noexcept to some std::promise shared state internals
    
    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.

Diff:
---
 libstdc++-v3/include/std/future | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/include/std/future b/libstdc++-v3/include/std/future
index 9e75ae98b13d..d7be205af506 100644
--- a/libstdc++-v3/include/std/future
+++ b/libstdc++-v3/include/std/future
@@ -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);


More information about the Gcc-cvs mailing list