File tree Expand file tree Collapse file tree 1 file changed +36
-5
lines changed Expand file tree Collapse file tree 1 file changed +36
-5
lines changed Original file line number Diff line number Diff line change @@ -75,20 +75,51 @@ class LoggerStream {
75
75
}
76
76
77
77
template <typename T>
78
- LoggerStream& operator <<(T obj) {
78
+ LoggerStream& operator <<(T const & obj) {
79
79
_out << obj;
80
80
return *this ;
81
81
}
82
82
83
83
template <typename T>
84
- LoggerStream& operator <<(std::vector<T> const & v) {
85
- for (auto const & i : v) _out << i << " " ;
84
+ LoggerStream& operator <<(std::vector<T> const & obj) {
85
+ _out << ' [' ;
86
+ size_t i = 0 ;
87
+ size_t const n = obj.size ();
88
+ for (auto const & it : obj) {
89
+ if (++i < n) {
90
+ _out << it << " , " ;
91
+ }
92
+ }
93
+ _out << ' ]' ;
86
94
return *this ;
87
95
}
88
96
89
97
template <typename T>
90
- LoggerStream& operator <<(std::unordered_set<T> const & us) {
91
- for (auto const & i : us) _out << i;
98
+ LoggerStream& operator <<(std::unordered_set<T> const & obj) {
99
+ _out << ' {' ;
100
+ size_t i = 0 ;
101
+ size_t const n = obj.size ();
102
+ for (auto const & it : obj) {
103
+ if (++i < n) {
104
+ _out << it << " , " ;
105
+ }
106
+ }
107
+ _out << ' }' ;
108
+ return *this ;
109
+ }
110
+
111
+ template <typename K, typename V>
112
+ LoggerStream& operator <<(std::unordered_map<K, V> const & obj) {
113
+ _out << ' {' ;
114
+ size_t i = 0 ;
115
+ size_t n = obj.size ();
116
+ for (auto const & it : obj) {
117
+ if (++i < n) {
118
+ _out << it << " , " ;
119
+ }
120
+ _out << it.first << " => " << it.second ;
121
+ }
122
+ _out << ' }' ;
92
123
return *this ;
93
124
}
94
125
You can’t perform that action at this time.
0 commit comments