|
38 | 38 | /**************************************************************************************************/
|
39 | 39 |
|
40 | 40 | namespace stlab {
|
41 |
| - |
42 |
| -/**************************************************************************************************/ |
43 |
| - |
44 |
| -inline namespace v1 { |
| 41 | +inline namespace STLAB_VERSION_NAMESPACE() { |
45 | 42 |
|
46 | 43 | /**************************************************************************************************/
|
47 | 44 |
|
@@ -274,8 +271,6 @@ struct shared_base<T, enable_if_copyable<T>> : std::enable_shared_from_this<shar
|
274 | 271 |
|
275 | 272 | explicit shared_base(executor_t s) : _executor(std::move(s)) {}
|
276 | 273 |
|
277 |
| - void reset() { _then.clear(); } // NEEDS MUTEX |
278 |
| - |
279 | 274 | template <typename F>
|
280 | 275 | auto recover(future<T>&& p, F&& f) {
|
281 | 276 | return recover(std::move(p), _executor, std::forward<F>(f));
|
@@ -389,8 +384,6 @@ struct shared_base<T, enable_if_not_copyable<T>> : std::enable_shared_from_this<
|
389 | 384 |
|
390 | 385 | explicit shared_base(executor_t s) : _executor(std::move(s)) {}
|
391 | 386 |
|
392 |
| - void reset() { _then.second = task<void() noexcept>{}; } |
393 |
| - |
394 | 387 | template <typename F>
|
395 | 388 | auto recover(future<T>&& p, F&& f) {
|
396 | 389 | return recover(std::move(p), _executor, std::forward<F>(f));
|
@@ -474,8 +467,6 @@ struct shared_base<void> : std::enable_shared_from_this<shared_base<void>> {
|
474 | 467 |
|
475 | 468 | explicit shared_base(executor_t s) : _executor(std::move(s)) {}
|
476 | 469 |
|
477 |
| - void reset() { _then.clear(); } |
478 |
| - |
479 | 470 | template <typename F>
|
480 | 471 | auto recover(future<result_type>&& p, F&& f) {
|
481 | 472 | return recover(std::move(p), _executor, std::forward<F>(f));
|
@@ -750,7 +741,11 @@ class STLAB_NODISCARD() future<T, enable_if_copyable<T>> {
|
750 | 741 | return _p->_exception ? std::optional<std::exception_ptr>{_p->_exception} : std::nullopt;
|
751 | 742 | }
|
752 | 743 |
|
753 |
| - std::exception_ptr exception() const& { return _p->_exception; } |
| 744 | + // Precondition: is_ready() |
| 745 | + std::exception_ptr exception() const& { |
| 746 | + assert(is_ready()); |
| 747 | + return _p->_exception; |
| 748 | + } |
754 | 749 | };
|
755 | 750 |
|
756 | 751 | /**************************************************************************************************/
|
@@ -897,7 +892,11 @@ class STLAB_NODISCARD() future<void, void> {
|
897 | 892 | return _p->_exception ? std::optional<std::exception_ptr>{_p->_exception} : std::nullopt;
|
898 | 893 | }
|
899 | 894 |
|
900 |
| - std::exception_ptr exception() const& { return _p->_exception; } |
| 895 | + // Precondition: is_ready() |
| 896 | + std::exception_ptr exception() const& { |
| 897 | + assert(is_ready()); |
| 898 | + return _p->_exception; |
| 899 | + } |
901 | 900 | };
|
902 | 901 |
|
903 | 902 | /**************************************************************************************************/
|
@@ -1001,7 +1000,11 @@ class STLAB_NODISCARD() future<T, enable_if_not_copyable<T>> {
|
1001 | 1000 | return _p->_exception ? std::optional<std::exception_ptr>{_p->_exception} : std::nullopt;
|
1002 | 1001 | }
|
1003 | 1002 |
|
1004 |
| - std::exception_ptr exception() const& { return _p->_exception; } |
| 1003 | + // Precondition: is_ready() |
| 1004 | + std::exception_ptr exception() const& { |
| 1005 | + assert(is_ready()); |
| 1006 | + return _p->_exception; |
| 1007 | + } |
1005 | 1008 | };
|
1006 | 1009 |
|
1007 | 1010 | template <typename Sig, typename E, typename F>
|
@@ -1233,7 +1236,7 @@ template <typename E, typename F, typename... Ts>
|
1233 | 1236 | auto when_all(E executor, F f, future<Ts>... args) {
|
1234 | 1237 | using vt_t = voidless_tuple<Ts...>;
|
1235 | 1238 | using opt_t = optional_placeholder_tuple<Ts...>;
|
1236 |
| - using result_t = decltype(detail::apply_tuple(std::declval<F>(), std::declval<vt_t>())); |
| 1239 | + using result_t = decltype(apply_ignore_placeholders(std::declval<F>(), std::declval<vt_t>())); |
1237 | 1240 |
|
1238 | 1241 | auto shared = std::make_shared<detail::when_all_shared<F, opt_t>>();
|
1239 | 1242 | auto p = package<result_t()>(
|
@@ -1816,10 +1819,7 @@ auto shared_base<void>::recover(future<result_type>&& p, E executor, F&& f) {
|
1816 | 1819 |
|
1817 | 1820 | /**************************************************************************************************/
|
1818 | 1821 |
|
1819 |
| -} // namespace v1 |
1820 |
| - |
1821 |
| -/**************************************************************************************************/ |
1822 |
| - |
| 1822 | +} // namespace STLAB_VERSION_NAMESPACE() |
1823 | 1823 | } // namespace stlab
|
1824 | 1824 |
|
1825 | 1825 | /**************************************************************************************************/
|
|
0 commit comments