Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <set>
- using namespace std;
- template <typename Documents>
- ostream& Print (ostream& out, const Documents& documents) {
- bool is_first = true;
- for (const auto& element : documents) {
- if (!is_first) {
- out << ", "s;
- }
- is_first = false;
- out << element;
- }
- return out;
- }
- template <typename Element>
- ostream& operator<<(ostream& out, const vector<Element>& container) {
- Print(out, container);
- return out;
- }
- template <typename Element>
- ostream& operator<<(ostream& out, const set<Element>& container) {
- Print(out, container);
- return out;
- }
- int main() {
- const set<string> cats = {"Мурка"s, "Белка"s, "Георгий"s, "Рюрик"s};
- cout << cats << endl;
- const vector<int> ages = {10, 5, 2, 12};
- cout << ages << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement