ConsecutiveValue Filter

template<typename T, size_t N>
struct ConsecutiveValue

Filter that requires N consecutive identical values.

This stateful filter propagates a change only when the same value has been received N consecutive times, providing strong debouncing for stable states.

Since

v0.1.0

// Example: Require 4 consecutive identical readings
Signal<bool, 10, ConsecutiveValue<bool, 4>> button(false);

Note

Stateful filter. Tracks consecutive count.

Warning

  • N must be greater than 0.

  • Type T must support operator==.

Template Parameters:
typename T

Any type.

size_t N

Number of consecutive occurrences required.

Public Functions

inline bool operator()(const T &old_value, const T &new_value) const

Public Members

mutable bool initialized = false
mutable size_t counter = 0
mutable T consecutive_value = T()

See Also