61#ifndef TPL_CA_MULTI_FIELD_RULE_H
62#define TPL_CA_MULTI_FIELD_RULE_H
76namespace ca_mf_rule_detail {
84template <
typename Tuple>
87template <
typename... Fields>
90 using type = std::tuple<Neighbor_View<Fields>...>;
97template <
typename FieldsTuple>
109template <
typename R,
typename FieldsTuple>
111 =
requires(
const R &
r,
const FieldsTuple &cur,
const Field_Neighbor_Views_Tuple<FieldsTuple> &nb) {
112 {
r(cur, nb) } -> std::convertible_to<FieldsTuple>;
124template <
typename R,
typename FieldsTuple, std::
size_t Rank>
126 const FieldsTuple &cur,
127 const Field_Neighbor_Views_Tuple<FieldsTuple> &nb,
128 const Cell_Context<Rank> &ctx) {
129 {
r(cur, nb, ctx) } -> std::convertible_to<FieldsTuple>;
133template <
typename R,
typename FieldsTuple, std::
size_t Rank>
152template <
typename Rule,
typename FieldsTuple, std::
size_t Rank>
154 const FieldsTuple &cur,
158 if constexpr (
requires {
r(cur, nb, ctx); })
159 return r(cur, nb, ctx);
180template <std::
size_t I,
typename Inner>
199 template <
typename FieldsTuple>
203 static_assert(I < std::tuple_size_v<FieldsTuple>,
"Field_Slice_Rule: I out of range");
204 FieldsTuple
out = cur;
205 std::get<I>(
out) =
inner_(std::get<I>(cur), std::get<I>(nb));
213 template <
typename FieldsTuple, std::
size_t Rank>
218 static_assert(I < std::tuple_size_v<FieldsTuple>,
"Field_Slice_Rule: I out of range");
219 FieldsTuple
out = cur;
220 if constexpr (
requires {
inner_(std::get<I>(cur), std::get<I>(nb), ctx); })
221 std::get<I>(
out) =
inner_(std::get<I>(cur), std::get<I>(nb), ctx);
223 std::get<I>(
out) =
inner_(std::get<I>(cur), std::get<I>(nb));
size_t size_t int32_t * out
Common typedefs and tag types for the Cellular Automata module.
Adaptor: apply a mono-field rule to field I, leave the other fields unchanged.
FieldsTuple operator()(const FieldsTuple &cur, const Field_Neighbor_Views_Tuple< FieldsTuple > &nb, const Cell_Context< Rank > &ctx) const
Contextual-form invocation.
FieldsTuple operator()(const FieldsTuple &cur, const Field_Neighbor_Views_Tuple< FieldsTuple > &nb) const
Pure-form invocation.
constexpr Field_Slice_Rule(Inner inner)
Wrap a mono-field rule.
Concept: a pure multi-field rule.
Concept: a contextual multi-field rule.
Concept: any supported multi-field rule signature.
typename ca_mf_rule_detail::neighbor_view_tuple< FieldsTuple >::type Field_Neighbor_Views_Tuple
std::tuple<Neighbor_View<F>...> for the field tuple std::tuple<F...>.
@ R
Recovered (and immune).
std::span< const T > Neighbor_View
Read-only view over a contiguous range of neighbour values.
FieldsTuple apply_multi_field_rule(const Rule &r, const FieldsTuple &cur, const Field_Neighbor_Views_Tuple< FieldsTuple > &nb, const Cell_Context< Rank > &ctx)
Invoke a multi-field rule with optional context forwarding.
Main namespace for Aleph-w library functions.
Per-cell context handed to rules that need to know "where" and "when" they are firing.
std::tuple< Neighbor_View< Fields >... > type
C++20 concepts for the Cellular Automata module.