8#include <yaclib/config.hpp>
14template <
typename Core, FailPolicy F>
15using ContainerElem = std::conditional_t<F == FailPolicy::FirstFail, wrap_void_t<typename Core::Value>,
24 using Value =
typename Head::Value;
27 if constexpr ((... && std::is_same_v<Value, typename Futures::Core::Value>)) {
29 return when::When<when::Join, F, void, OutputTrait>(std::move(
futures)...);
31 using OutputValue = std::vector<ContainerElem<Head, F>>;
32 return when::When<when::All, F, OutputValue, OutputTrait>(std::move(
futures)...);
35 using OutputValue = std::tuple<ContainerElem<typename Futures::Core, F>...>;
36 return when::When<when::AllTuple, F, OutputValue, OutputTrait>(std::move(
futures)...);
40template <FailPolicy F = FailPolicy::FirstFail,
typename It,
typename = std::enable_if_t<is_input_iterator_v<It>>>
42 using T =
typename std::iterator_traits<It>::value_type;
45 if constexpr (std::is_same_v<typename T::Core::Value, void> && F !=
FailPolicy::None) {
46 return when::When<when::Join, F, void, OutputTrait>(
begin, count);
48 using OutputValue = std::vector<ContainerElem<typename T::Core, F>>;
49 return when::When<when::All, F, OutputValue, OutputTrait>(
begin, count);
54 typename = std::enable_if_t<is_input_range_pair_v<It, Sentinel>>>
58 "Use WhenAll(begin, std::distance(begin, end)) instead");
64template <FailPolicy F = FailPolicy::FirstFail,
typename Range,
typename = std::enable_if_t<is_input_range_v<Range>>>
Encapsulated return value from caller.
YACLIB_INLINE void CheckSameTrait()
Contract< V, T > MakeContract()
Creates related future and promise.
typename detail::Head< Args... >::Type head_t
std::conditional_t< F==FailPolicy::FirstFail, wrap_void_t< typename Core::Value >, typename Core::Trait::template Result< typename Core::Value > > ContainerElem
FailPolicy
This Policy describe how algorithm interpret if Future will be fulfilled by fail (exception or error)
YACLIB_INLINE auto WhenAll(Futures... futures)