fork(1) download
  1. #include <iostream>
  2. #include <string>
  3. int main() {
  4. struct
  5. {
  6. bool first = true;
  7. [[nodiscard]] auto to_string() -> std::string
  8. {
  9. if (first)
  10. {
  11. first = false;
  12. return "";
  13. }
  14. else
  15. {
  16. return ", ";
  17. }
  18. }
  19. } separator;
  20. std::cout << separator.to_string() + "a" + separator.to_string() + "b" + separator.to_string() + "c" << '\n';
  21. }
Success #stdin #stdout 0s 4704KB
stdin
Standard input is empty
stdout
, a, bc