fork download
  1. #include <cstdarg>
  2. #include <iostream>
  3. #include <vector>
  4.  
  5. void SendMsg(int x, std::string format, ...)
  6. {
  7. va_list vl;
  8. va_start(vl, format);
  9. vprintf(format.c_str(), vl);
  10. va_end(vl);
  11. std::cout << std::endl;
  12. };
  13.  
  14. template <typename... Ts>
  15. void FOO(int x, const std::string& format, Ts... args)
  16. {
  17. SendMsg(x, format + "%s %d", args..., "xyz", 123);
  18. }
  19.  
  20. void FOO(int x)
  21. {
  22. SendMsg(x, "%s %d", "xyz", 123);
  23. }
  24.  
  25. int main()
  26. {
  27. FOO(42, "prefix %f ", 4.2f);
  28. FOO(42);
  29. }
  30.  
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
prefix 4.200000 xyz 123
xyz 123