Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- template <typename T>
- std::ostream& operator <<(std::ostream& text, const std::vector<T>& vec) {
- if (vec.empty()) {
- return text << "[]";
- }
- auto current = vec.begin();
- auto last = --vec.end();
- text << '[';
- for (; current != last; ++current) {
- text << *current << ", ";
- }
- return text << *last << ']';
- }
- int main() {
- std::vector<int> vec = {1, 2, 3};
- std::cout << vec;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement