Common System 0.2.0
Common interfaces and patterns for system integration
Loading...
Searching...
No Matches
kcenon::common::concepts::Chainable Concept Referenceexport

A type that supports monadic chaining (flatMap/and_then). More...

#include <core.h>

Concept definition

template<typename T>
concept kcenon::common::concepts::Chainable = requires(const T t) {
{ t.and_then(std::declval<std::function<T(typename T::value_type)>>()) };
}
A type that supports monadic chaining (flatMap/and_then).
Definition core.h:121

Detailed Description

A type that supports monadic chaining (flatMap/and_then).

Types satisfying this concept can chain operations that return the same container type, enabling fluent error handling.

Example usage:

template<Chainable C>
auto chain_operations(const C& container) {
return container.and_then([](auto& val) {
return C::ok(val + 1);
});
}

Definition at line 121 of file core.h.