1
0

cmake-string-concatenation-use-cmstrcat.cxx 807 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 = a + b;
  15. concat = a + " and this is a string literal";
  16. concat = a + 'O';
  17. concat = "This is a string literal" + b;
  18. concat = 'O' + a;
  19. concat = a + " and this is a string literal" + 'O' + b;
  20. concat += b;
  21. concat += " and this is a string literal";
  22. concat += 'o';
  23. concat += b + " and this is a string literal " + 'o' + b;
  24. std::pair<std::string, std::string> p;
  25. concat = 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. }