fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. template<typename A1, typename A2>
  5. struct printer
  6. {
  7. void print(A1 const& a1, A2 const& a2)
  8. {
  9. std::cout << a1 << " " << a2 << "\n";
  10. }
  11.  
  12. void print(void** args)
  13. {
  14. print(*static_cast<A1*>(args[0]), *static_cast<A2*>(args[1]));
  15. }
  16. };
  17.  
  18. int main()
  19. {
  20. printer<std::string, int> my_printer;
  21. my_printer.print("Test", 1);
  22.  
  23. std::string a1 = "Test";
  24. int a2 = 2;
  25. void* args[] = { &a1, &a2 };
  26. my_printer.print(args);
  27. }
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
Test 1
Test 2