Guest User

Untitled

a guest
Oct 26th, 2015
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void printf(const std::function<void(char)> &putc, const char *format, ...);
  2.  
  3. class lambda {
  4.     char *buffer;
  5.     int &idx;
  6.     void f(char c) {
  7.         this->buffer[this->idx++] = c;
  8.     }
  9. };
  10.  
  11. void printSomething()
  12. {
  13.     char buffer[128];
  14.     int idx = 0;
  15.     // [&idx](char c) { buffer[idx++] = c; }
  16.     lambda f { buffer, idx };
  17.     printf(f, "Hello %s\n", "World");
  18. }
Advertisement
Add Comment
Please, Sign In to add comment