In embedded and firmware systems, callbacks are commonly used to react to events such as timers, interrupts, or state changes.
This task focuses on using a C++ lambda as a callback that captures and modifies local state without explicitly specifying its type.
Your task is to create a callback that increments a counter each time it is invoked.
You must follow the given constraints exactly, as they are designed to reinforce modern Embedded C++ best practices.
Task:
n from input.count initialized to 0.count and increments it by 1 each time it is called.n times using the provided loop.count.Input Specification:
nn represents how many times the callback should be invokedOutput Specification:
count after the callback has been called n times
Example
Input:
3Output:
3
Constraints:
0 ≤ n ≤ 10^6countstd::functiontypenamefor loop must not be modified
Input
0
Expected Output
0