| 1923 | // or any of the futures returned from the invocations of `.then()`. |
| 1924 | template <typename T> |
| 1925 | Future<T> undiscardable(const Future<T>& future) |
| 1926 | { |
| 1927 | std::unique_ptr<Promise<T>> promise(new Promise<T>()); |
| 1928 | Future<T> future_ = promise->future(); |
| 1929 | future.onAny(lambda::partial( |
| 1930 | [](std::unique_ptr<Promise<T>> promise, const Future<T>& future) { |
| 1931 | promise->associate(future); |
| 1932 | }, |
| 1933 | std::move(promise), |
| 1934 | lambda::_1)); |
| 1935 | return future_; |
| 1936 | } |
| 1937 | |
| 1938 | |
| 1939 | // Decorator that for some callable `f` invokes |