Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void printf(const std::function<void(char)> &putc, const char *format, ...);
- class lambda {
- char *buffer;
- int &idx;
- void f(char c) {
- this->buffer[this->idx++] = c;
- }
- };
- void printSomething()
- {
- char buffer[128];
- int idx = 0;
- // [&idx](char c) { buffer[idx++] = c; }
- lambda f { buffer, idx };
- printf(f, "Hello %s\n", "World");
- }
Advertisement
Add Comment
Please, Sign In to add comment