cmake-string-concatenation-use-cmstrcat-fixit.cxx 832 B

123456789101112131415161718192021222324252627282930313233343536
  1. #include <string>
  2. template <typename... Args>
  3. std::string cmStrCat(Args&&... args)
  4. {
  5. return "";
  6. }
  7. std::string a = "This is a string variable";
  8. std::string b = " and this is a string variable";
  9. std::string concat;
  10. // Correction needed
  11. void test1()
  12. {
  13. concat = cmStrCat(a, b);
  14. concat = cmStrCat(a, " and this is a string literal");
  15. concat = cmStrCat(a, 'O');
  16. concat = cmStrCat("This is a string literal", b);
  17. concat = cmStrCat('O', a);
  18. concat = cmStrCat(a, " and this is a string literal", 'O', b);
  19. concat = cmStrCat(concat, b);
  20. concat = cmStrCat(concat, " and this is a string literal");
  21. concat = cmStrCat(concat, 'o');
  22. concat = cmStrCat(concat, b, " and this is a string literal ", 'o', b);
  23. }
  24. // No correction needed
  25. void test2()
  26. {
  27. a = b;
  28. a = "This is a string literal";
  29. a = 'X';
  30. cmStrCat(a, b);
  31. }