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

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