14#ifndef ZYPPNG_PIPELINES_ALGORITHM_H_INCLUDED
15#define ZYPPNG_PIPELINES_ALGORITHM_H_INCLUDED
19#include <zypp-core/ng/pipelines/operators.h>
29 if ( value )
return true;
37 template <
class Container,
class Transformation,
class Predicate,
class DefaultType,
typename sfinae =
void >
40 template <
class Container,
class Transformation,
class Predicate,
class DefaultType,
typename sfinae >
44 static_assert( std::is_invocable_v<Transformation, InputType>,
"Transformation function must take the container value type as input " );
46 using OutputType = std::invoke_result_t<Transformation, InputType>;
48 template <
typename C = Container>
49 static auto execute ( C &&container, Transformation transFunc, DefaultType defaultVal, Predicate predicate) {
50 static_assert( std::is_same_v<OutputType, DefaultType>,
"Default type and transformation result type must match" );
52 for (
auto &in : std::forward<C>(container) ) {
54 if ( predicate(res) ) {
62 template <
class Transformation,
class Predicate,
class DefaultType >
65 FirstOfHelper( Transformation transFunc, DefaultType defaultVal, Predicate predicate )
70 template <
class Container
73 static_assert( std::is_rvalue_reference_v<decltype(std::forward<Container>(container))>,
"Input container must be a rvalue reference" );
93 template <
class Transformation,
class DefaultType,
class Predicate >
100 template <
typename Excpt,
typename ...Rest>
103 if constexpr (
sizeof...(Rest) == 0 ) {
105 std::rethrow_exception ( exceptionPtr );
109 }
catch (
const Excpt &e ) {
131 template <
typename ...Excpt>
152 template <
typename Excpt>
155 std::rethrow_exception ( exceptionPtr );;
156 }
catch (
const Excpt &e ) {
165#ifdef ZYPP_ENABLE_ASYNC
166#include <zypp-core/ng/async/pipelines/algorithm.hpp>
Base class for Exception.
std::enable_if< std::is_member_pointer< typenamestd::decay< Functor >::type >::value, typenamestd::result_of< Functor &&(Args &&...)>::type >::type invoke(Functor &&f, Args &&... args)
Easy-to use interface to the ZYPP dependency resolver.
bool containsOneOfExceptionImpl(const std::exception_ptr &exceptionPtr)
bool containsOneOfException(const std::exception_ptr &exceptionPtr)
auto firstOf(Transformation &&transformFunc, DefaultType &&def, Predicate &&predicate=detail::ContinueUntilValidPredicate())
bool containsException(const std::exception_ptr &exceptionPtr)
bool operator()(const Arg &value)
FirstOfHelper(Transformation transFunc, DefaultType defaultVal, Predicate predicate)
Transformation _transFunc
auto operator()(Container &&container)
typename Container::value_type InputType
std::invoke_result_t< Transformation, InputType > OutputType
static auto execute(C &&container, Transformation transFunc, DefaultType defaultVal, Predicate predicate)