View difference between Paste ID: jEnpmeAm and 5sjC4L3U
SHOW: | | - or go back to the newest paste.
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-
	printf([&idx](char c) { buffer[idx++] = c; }, "Hello %s\n", "World");
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
}