mirror of
https://github.com/Naios/continuable.git
synced 2025-12-06 16:56:44 +08:00
Move the composition functions to it's own header
This commit is contained in:
parent
fbd87787aa
commit
7c0aa6e6ba
@ -720,54 +720,6 @@ using detail::types::dispatch_error_tag;
|
|||||||
///
|
///
|
||||||
/// \since 2.0.0
|
/// \since 2.0.0
|
||||||
using detail::types::error_type;
|
using detail::types::error_type;
|
||||||
|
|
||||||
/// Connects the given continuables with an *all* logic.
|
|
||||||
///
|
|
||||||
/// \param continuables The continuable_base objects to connect.
|
|
||||||
/// Requires at least 2 objects to connect.
|
|
||||||
///
|
|
||||||
/// \see continuable_base::operator && for details.
|
|
||||||
///
|
|
||||||
/// \since 1.1.0
|
|
||||||
template <typename... Continuables>
|
|
||||||
auto when_all(Continuables&&... continuables) {
|
|
||||||
static_assert(sizeof...(continuables) >= 2,
|
|
||||||
"Requires at least 2 continuables!");
|
|
||||||
return CONTINUABLE_FOLD_EXPRESSION(
|
|
||||||
&&, std::forward<Continuables>(continuables)...);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Connects the given continuables with an *any* logic.
|
|
||||||
///
|
|
||||||
/// \param continuables The continuable_base objects to connect.
|
|
||||||
/// Requires at least 2 objects to connect.
|
|
||||||
///
|
|
||||||
/// \see continuable_base::operator|| for details.
|
|
||||||
///
|
|
||||||
/// \since 1.1.0
|
|
||||||
template <typename... Continuables>
|
|
||||||
auto when_any(Continuables&&... continuables) {
|
|
||||||
static_assert(sizeof...(continuables) >= 2,
|
|
||||||
"Requires at least 2 continuables!");
|
|
||||||
return CONTINUABLE_FOLD_EXPRESSION(
|
|
||||||
||, std::forward<Continuables>(continuables)...);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Connects the given continuables with a *seq* logic.
|
|
||||||
///
|
|
||||||
/// \param continuables The continuable_base objects to connect.
|
|
||||||
/// Requires at least 2 objects to connect.
|
|
||||||
///
|
|
||||||
/// \see continuable_base::operator>> for details.
|
|
||||||
///
|
|
||||||
/// \since 1.1.0
|
|
||||||
template <typename... Continuables>
|
|
||||||
auto when_seq(Continuables&&... continuables) {
|
|
||||||
static_assert(sizeof...(continuables) >= 2,
|
|
||||||
"Requires at least 2 continuables!");
|
|
||||||
return CONTINUABLE_FOLD_EXPRESSION(
|
|
||||||
>>, std::forward<Continuables>(continuables)...);
|
|
||||||
}
|
|
||||||
} // namespace cti
|
} // namespace cti
|
||||||
|
|
||||||
#endif // CONTINUABLE_BASE_HPP_INCLUDED
|
#endif // CONTINUABLE_BASE_HPP_INCLUDED
|
||||||
|
|||||||
89
include/continuable/continuable-compositions.hpp
Normal file
89
include/continuable/continuable-compositions.hpp
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
/~` _ _ _|_. _ _ |_ | _
|
||||||
|
\_,(_)| | | || ||_|(_||_)|(/_
|
||||||
|
|
||||||
|
https://github.com/Naios/continuable
|
||||||
|
v3.0.0
|
||||||
|
|
||||||
|
Copyright(c) 2015 - 2018 Denis Blank <denis.blank at outlook dot com>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files(the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions :
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
**/
|
||||||
|
|
||||||
|
#ifndef CONTINUABLE_COMPOSITIONS_HPP_INCLUDED
|
||||||
|
#define CONTINUABLE_COMPOSITIONS_HPP_INCLUDED
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
#include <continuable/continuable-base.hpp>
|
||||||
|
#include <continuable/detail/features.hpp>
|
||||||
|
|
||||||
|
namespace cti {
|
||||||
|
/// Connects the given continuables with an *all* logic.
|
||||||
|
///
|
||||||
|
/// \param continuables The continuable_base objects to connect.
|
||||||
|
/// Requires at least 2 objects to connect.
|
||||||
|
///
|
||||||
|
/// \see continuable_base::operator && for details.
|
||||||
|
///
|
||||||
|
/// \since 1.1.0
|
||||||
|
template <typename... Continuables>
|
||||||
|
auto when_all(Continuables&&... continuables) {
|
||||||
|
static_assert(sizeof...(continuables) >= 2,
|
||||||
|
"Requires at least 2 continuables!");
|
||||||
|
return CONTINUABLE_FOLD_EXPRESSION(
|
||||||
|
&&, std::forward<Continuables>(continuables)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Connects the given continuables with an *any* logic.
|
||||||
|
///
|
||||||
|
/// \param continuables The continuable_base objects to connect.
|
||||||
|
/// Requires at least 2 objects to connect.
|
||||||
|
///
|
||||||
|
/// \see continuable_base::operator|| for details.
|
||||||
|
///
|
||||||
|
/// \since 1.1.0
|
||||||
|
template <typename... Continuables>
|
||||||
|
auto when_any(Continuables&&... continuables) {
|
||||||
|
static_assert(sizeof...(continuables) >= 2,
|
||||||
|
"Requires at least 2 continuables!");
|
||||||
|
return CONTINUABLE_FOLD_EXPRESSION(
|
||||||
|
||, std::forward<Continuables>(continuables)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Connects the given continuables with a *seq* logic.
|
||||||
|
///
|
||||||
|
/// \param continuables The continuable_base objects to connect.
|
||||||
|
/// Requires at least 2 objects to connect.
|
||||||
|
///
|
||||||
|
/// \see continuable_base::operator>> for details.
|
||||||
|
///
|
||||||
|
/// \since 1.1.0
|
||||||
|
template <typename... Continuables>
|
||||||
|
auto when_seq(Continuables&&... continuables) {
|
||||||
|
static_assert(sizeof...(continuables) >= 2,
|
||||||
|
"Requires at least 2 continuables!");
|
||||||
|
return CONTINUABLE_FOLD_EXPRESSION(
|
||||||
|
>>, std::forward<Continuables>(continuables)...);
|
||||||
|
}
|
||||||
|
} // namespace cti
|
||||||
|
|
||||||
|
#endif // CONTINUABLE_COMPOSITIONS_HPP_INCLUDED
|
||||||
@ -46,6 +46,7 @@
|
|||||||
namespace cti {}
|
namespace cti {}
|
||||||
|
|
||||||
#include <continuable/continuable-base.hpp>
|
#include <continuable/continuable-base.hpp>
|
||||||
|
#include <continuable/continuable-compositions.hpp>
|
||||||
#include <continuable/continuable-promise-base.hpp>
|
#include <continuable/continuable-promise-base.hpp>
|
||||||
#include <continuable/continuable-trait.hpp>
|
#include <continuable/continuable-trait.hpp>
|
||||||
#include <continuable/continuable-transforms.hpp>
|
#include <continuable/continuable-transforms.hpp>
|
||||||
|
|||||||
@ -2,6 +2,7 @@ set(LIB_SOURCES
|
|||||||
${CMAKE_SOURCE_DIR}/include/continuable/continuable.hpp
|
${CMAKE_SOURCE_DIR}/include/continuable/continuable.hpp
|
||||||
${CMAKE_SOURCE_DIR}/include/continuable/continuable-types.hpp
|
${CMAKE_SOURCE_DIR}/include/continuable/continuable-types.hpp
|
||||||
${CMAKE_SOURCE_DIR}/include/continuable/continuable-base.hpp
|
${CMAKE_SOURCE_DIR}/include/continuable/continuable-base.hpp
|
||||||
|
${CMAKE_SOURCE_DIR}/include/continuable/continuable-compositions.hpp
|
||||||
${CMAKE_SOURCE_DIR}/include/continuable/continuable-trait.hpp
|
${CMAKE_SOURCE_DIR}/include/continuable/continuable-trait.hpp
|
||||||
${CMAKE_SOURCE_DIR}/include/continuable/continuable-promise-base.hpp
|
${CMAKE_SOURCE_DIR}/include/continuable/continuable-promise-base.hpp
|
||||||
${CMAKE_SOURCE_DIR}/include/continuable/continuable-transforms.hpp
|
${CMAKE_SOURCE_DIR}/include/continuable/continuable-transforms.hpp
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user