cpptime
cpptime copied to clipboard
Input arguments to handler
Is it possible to extend the timer functionality to pass input argument((void *)arg) to handler function?
Hello @hemalbavishi and sorry for the very late reply,
Not sure if you are still interested, but I answer it anyway in case it helps somebody.
The handler function is a std::function
. It is therefore possible to use e.g. a lambda and pass additional data to it, either by moving, copying or sharing. The best way to do it depends on the shared data.
I added an example in the tests that shows how to share (by copy) a shared_ptr
with a lambda, which is used as the handler function.