fork download
  1. #include <iostream>
  2. #include <functional>
  3. using namespace std;
  4.  
  5. void withStackMemory(size_t size, function<void(void*)> body) {
  6. char buffer[size];
  7. body(buffer);
  8. }
  9.  
  10. int main() {
  11.  
  12. function<void(void*)> fn = [](void* x){ cout << x << endl; };
  13.  
  14. withStackMemory(5, fn);
  15.  
  16. return 0;
  17. }
Success #stdin #stdout 0s 4464KB
stdin
Standard input is empty
stdout
0x7ffc30159f80