1
0

cmake-string-concatenation-use-cmstrcat.cxx 715 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 = a + b;
  14. concat = a + " and this is a string literal";
  15. concat = a + 'O';
  16. concat = "This is a string literal" + b;
  17. concat = 'O' + a;
  18. concat = a + " and this is a string literal" + 'O' + b;
  19. concat += b;
  20. concat += " and this is a string literal";
  21. concat += 'o';
  22. 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. }