fork(1) download
  1. #include <iostream>
  2. #include <functional>
  3.  
  4. struct myStruct {
  5. int data;
  6. };
  7.  
  8. void get_data(struct myStruct* const value, const void * const data) {
  9. std::cout << "called!" << std::endl;
  10. value->data = 12345;
  11. }
  12.  
  13. template<typename MyType>
  14. void process(bool test, const std::function<void(MyType* const, const void* const)>& callb) {
  15. MyType t;
  16. callb(&t, nullptr);
  17. std::cout << t.data << std::endl;
  18. }
  19.  
  20. int main() {
  21. bool test1 = true;
  22. process<myStruct>(test1, get_data);
  23. return 0;
  24. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
called!
12345