#pragma once #include #include "stream.pre.h" #include "../result.h" namespace asyncpp { template< typename T_value, typename T_derived> struct base_stream : public tag_stream { public: using value_type = T_value; using result_type = stream_result; using derived_type = T_derived; using this_type = base_stream; public: /** * @brief Execute the given lambda for each element in the stream. * * @return Returns a future that completes once the stream is finished. */ template< chaining_mode X_mode = copy, typename X_lambda> inline auto for_each(X_lambda&& p_lambda) &; /** * @brief Execute the given lambda for each element in the stream. * * @return Returns a future that completes once the stream is finished. */ template< chaining_mode X_mode = move, typename X_lambda> inline auto for_each(X_lambda&& p_lambda) &&; public: /** * @brief Transforms the stream from one type to another type * by executing the passed lambda for each value. */ template< chaining_mode X_mode = copy, typename X_lambda> inline auto map(X_lambda&& p_lambda) &; /** * @brief Transforms the stream from one type to another type * by executing the passed lambda for each value. */ template< chaining_mode X_mode = move, typename X_lambda> inline auto map(X_lambda&& p_lambda) &&; public: /** * @brief Flatten the stream of streams to a single stream. */ template< chaining_mode X_mode = copy> inline auto flatten() &; /** * @brief Flatten the stream of streams to a single stream. */ template< chaining_mode X_mode = move> inline auto flatten() &&; #ifdef ASYNCPP_ENABLE_FEATURE_TIMING public: /** * @brief Throw an execption if the timeout has passed. * * This method is only enabled if timer.h is included before. */ template< chaining_mode X_mode = copy, typename X_base, typename X_ratio> inline auto timeout(const duration& p_timeout) &; /** * @brief Throw an execption if the timeout has passed. * * This method is only enabled if timer.h is included before. */ template< chaining_mode X_mode = move, typename X_base, typename X_ratio> inline auto timeout(const duration& p_timeout) &&; #endif }; }