summaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/std/future
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/include/std/future')
-rw-r--r--libstdc++-v3/include/std/future35
1 files changed, 23 insertions, 12 deletions
diff --git a/libstdc++-v3/include/std/future b/libstdc++-v3/include/std/future
index fea915b0a87..8ba13069510 100644
--- a/libstdc++-v3/include/std/future
+++ b/libstdc++-v3/include/std/future
@@ -95,11 +95,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/
class future_error : public logic_error
{
- error_code _M_code;
-
public:
- explicit future_error(error_code __ec)
- : logic_error("std::future_error: " + __ec.message()), _M_code(__ec)
+ explicit
+ future_error(future_errc __errc)
+ : future_error(std::make_error_code(__errc))
{ }
virtual ~future_error() noexcept;
@@ -109,6 +108,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
const error_code&
code() const noexcept { return _M_code; }
+
+ private:
+ explicit
+ future_error(error_code __ec)
+ : logic_error("std::future_error: " + __ec.message()), _M_code(__ec)
+ { }
+
+ friend void __throw_future_error(int);
+
+ error_code _M_code;
};
// Forward declarations.
@@ -426,8 +435,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
if (static_cast<bool>(__res))
{
- error_code __ec(make_error_code(future_errc::broken_promise));
- __res->_M_error = make_exception_ptr(future_error(__ec));
+ __res->_M_error =
+ make_exception_ptr(future_error(future_errc::broken_promise));
// This function is only called when the last asynchronous result
// provider is abandoning this shared state, so noone can be
// trying to make the shared state ready at the same time, and
@@ -769,7 +778,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
return std::move(this->_M_get_result()._M_value());
}
- shared_future<_Res> share();
+ shared_future<_Res> share() noexcept;
};
/// Partial specialization for future<R&>
@@ -812,7 +821,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
return this->_M_get_result()._M_get();
}
- shared_future<_Res&> share();
+ shared_future<_Res&> share() noexcept;
};
/// Explicit specialization for future<void>
@@ -855,7 +864,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
this->_M_get_result();
}
- shared_future<void> share();
+ shared_future<void> share() noexcept;
};
@@ -995,18 +1004,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
: _M_state(std::move(__uf._M_state))
{ }
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 2556. Wide contract for future::share()
template<typename _Res>
inline shared_future<_Res>
- future<_Res>::share()
+ future<_Res>::share() noexcept
{ return shared_future<_Res>(std::move(*this)); }
template<typename _Res>
inline shared_future<_Res&>
- future<_Res&>::share()
+ future<_Res&>::share() noexcept
{ return shared_future<_Res&>(std::move(*this)); }
inline shared_future<void>
- future<void>::share()
+ future<void>::share() noexcept
{ return shared_future<void>(std::move(*this)); }
/// Primary template for promise