fork(1) download
  1. #include <vector>
  2. #include <string>
  3. #include <iostream>
  4. #include <iomanip>
  5. #include <set>
  6. #include <type_traits>
  7.  
  8. using namespace std;
  9.  
  10. template <typename Container,
  11. typename = enable_if_t<!is_same<Container,string>::value>>
  12. ostream& operator<<(ostream& out, const Container& container)
  13. {
  14. bool isnt_first = false;
  15. for (const auto& element : container)
  16. {
  17. if (isnt_first) {
  18. out << ", "s << element;
  19. }
  20. else {
  21. out << element;
  22. isnt_first = true;
  23. }
  24. }
  25. return out;
  26. }
  27.  
  28. int main() {
  29.  
  30. //setlocale(LC_ALL, "ru");
  31.  
  32. const set<string> cats = { "Мурка"s, "Белка"s, "Георгий"s, "Рюрик"s };
  33. cout << cats << endl;
  34. return 0;
  35. }
  36.  
  37.  
Success #stdin #stdout 0.01s 5460KB
stdin
Standard input is empty
stdout
Белка, Георгий, Мурка, Рюрик