fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template <typename T>
  5. void static_dispatch(const T &callback) {
  6. cout << "static_dipatch: " << callback() << endl;
  7. }
  8.  
  9. int main() {
  10. int x = 1;
  11. int y = 2;
  12.  
  13. auto closure = [&] { return x + y; };
  14.  
  15. static_dispatch(closure);
  16.  
  17. return 0;
  18. }
Success #stdin #stdout 0s 3096KB
stdin
Standard input is empty
stdout
static_dipatch: 3