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