MCPcopy Create free account
hub / github.com/SmingHub/Sming / callLambda

Method callLambda

samples/Basic_Delegates/app/application.cpp:45–62  ·  view source on GitHub ↗

This example shows how to use a lambda expression as a callback

Source from the content-addressed store, hash-verified

43
44 // This example shows how to use a lambda expression as a callback
45 void callLambda()
46 {
47 int foo = 123;
48 taskTimer
49 .initializeMs(
50 taskInterval,
51 [foo] // capture just foo by value (Note it would be bad to pass by reference as foo would be out of scope when the lambda function runs later)
52 () // No parameters to the callback
53 -> void // Returns nothing
54 {
55 if(foo == 123) {
56 debugf("lambda Callback foo is 123");
57 } else {
58 debugf("lambda Callback foo is not 123, crikey!");
59 }
60 })
61 .start();
62 }
63
64 // This example shows how to use a member function as a callback
65 void callMemberFunction()

Callers 1

initFunction · 0.80

Calls 1

startMethod · 0.45

Tested by

no test coverage detected