2 ms·
This has me thinking about doing Node.JS-style event processing with the new C++ lambda syntax. I guess you can do it, but you must always copy [=] into the cl
by jhallenworld 12y ago
This has me thinking about doing Node.JS-style event processing with the new C++ lambda syntax. I guess you can do it, but you must always copy [=] into the closure so that the io function can return:
void fred()
{
int first = 'x';
int second = 'y';
wait_key([=](int c) {
if (c == x) {
wait_key([=](int d) {
if (d == y) {
printf("got x and y\n");
}
});
}
});
}
wait_key(void (*func)(int c)) registers a callback then returns. When a key is processed func is called.
- mkup 12y agoThis approach to porting node.js library to C++11 is implemented in node.native library: https://github.com/d5/node.native https://github.com/d5/node.native