Changeset d3f9ad
- Timestamp:
- Jun 26, 2013, 2:19:11 PM (12 years ago)
- Children:
- df5994
- Parents:
- 73e948
- git-author:
- Frederik Heber <heber@…> (06/26/13 14:17:39)
- git-committer:
- Frederik Heber <heber@…> (06/26/13 14:19:11)
- File:
-
- 1 edited
-
src/CodePatterns/toString.hpp (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/CodePatterns/toString.hpp
r73e948 rd3f9ad 19 19 #include <sstream> 20 20 21 #include <deque> 21 22 #include <list> 22 23 #include <map> 24 #include <queue> 23 25 #include <set> 24 26 #include <vector> 25 27 26 28 29 /** Operator for output to std::ostream operator of an std::deque of arbitrary 30 * type. 31 * @param ost output stream 32 * @param _deque deque of types to output 33 * @return ost output stream 34 */ 35 template <class T, class alloc> std::ostream & operator<<(std::ostream &ost, const std::deque< T, alloc > &_deque) 36 { 37 ost << "( "; 38 for (typename std::deque< T, alloc >::const_iterator iter = _deque.begin(); 39 iter != _deque.end(); 40 ++iter) 41 ost << *iter << "; "; 42 ost << ")"; 43 return ost; 44 } 45 46 27 47 /** Operator for output to std::ostream operator of an std::list of arbitrary 28 48 * type. 29 49 * @param ost output stream 30 * @param vectorlist of types to output31 * @return ost output stream 32 */ 33 template <class T > std::ostream & operator<<(std::ostream &ost, const std::list< T > &_vector)34 { 35 ost << "( "; 36 for (typename std::list< T >::const_iterator iter = _vector.begin();37 iter != _ vector.end();50 * @param _list list of types to output 51 * @return ost output stream 52 */ 53 template <class T, class alloc> std::ostream & operator<<(std::ostream &ost, const std::list< T, alloc > &_list) 54 { 55 ost << "( "; 56 for (typename std::list< T, alloc >::const_iterator iter = _list.begin(); 57 iter != _list.end(); 38 58 ++iter) 39 59 ost << *iter << "; "; … … 49 69 * @return ost output stream 50 70 */ 51 template <class T, class S > std::ostream & operator<<(std::ostream &ost, const std::map< T, S > &_vector)71 template <class T, class S, class comp, class alloc> std::ostream & operator<<(std::ostream &ost, const std::map< T, S, comp, alloc > &_map) 52 72 { 53 73 ost << "{ "; 54 for (typename std::map< T, S >::const_iterator iter = _vector.begin();55 iter != _ vector.end();74 for (typename std::map< T, S, comp, alloc >::const_iterator iter = _map.begin(); 75 iter != _map.end(); 56 76 ++iter) 57 77 ost << "(" << iter->first << ")=>(" << iter->second << "); "; … … 60 80 } 61 81 62 63 82 /** Operator for output to std::ostream operator of an std::multimap of arbitrary 64 83 * type. … … 67 86 * @return ost output stream 68 87 */ 69 template <class T, class S > std::ostream & operator<<(std::ostream &ost, const std::multimap< T, S > &_vector)88 template <class T, class S, class comp, class alloc> std::ostream & operator<<(std::ostream &ost, const std::multimap< T, S, comp, alloc > &_multimap) 70 89 { 71 90 ost << "{ "; 72 for (typename std::multimap< T, S >::const_iterator iter = _vector.begin();73 iter != _ vector.end();91 for (typename std::multimap< T, S, comp, alloc >::const_iterator iter = _multimap.begin(); 92 iter != _multimap.end(); 74 93 ++iter) 75 94 ost << "(" << iter->first << ")=>(" << iter->second << "); "; … … 78 97 } 79 98 99 /** Operator for output to std::ostream operator of an std::multiset of arbitrary 100 * type. 101 * @param ost output stream 102 * @param multiset list of types to output 103 * @return ost output stream 104 */ 105 template <class T, class comp, class alloc> std::ostream & operator<<(std::ostream &ost, const std::multiset< T, comp, alloc > &_multiset) 106 { 107 ost << "( "; 108 for (typename std::multiset< T, comp, alloc >::const_iterator iter = _multiset.begin(); 109 iter != _multiset.end(); 110 ++iter) 111 ost << *iter << "; "; 112 ost << ")"; 113 return ost; 114 } 115 116 /** Operator for output to std::ostream operator of an std::pair of arbitrary 117 * type. 118 * @param ost output stream 119 * @param _pair pair of types to output 120 * @return ost output stream 121 */ 122 template <class T, class S> std::ostream & operator<<(std::ostream &ost, const std::pair< T, S > &_pair) 123 { 124 ost << "[" << _pair.first << "," << _pair.second << "]"; 125 return ost; 126 } 127 128 /** Operator for output to std::ostream operator of an std::priority_queue of arbitrary 129 * type. 130 * @param ost output stream 131 * @param _priority_queue queue of types to output 132 * @return ost output stream 133 */ 134 template <class T, class alloc> std::ostream & operator<<(std::ostream &ost, const std::priority_queue< T, alloc > &_priority_queue) 135 { 136 ost << "( "; 137 for (typename std::priority_queue< T, alloc >::const_iterator iter = _priority_queue.begin(); 138 iter != _priority_queue.end(); 139 ++iter) 140 ost << *iter << "; "; 141 ost << ")"; 142 return ost; 143 } 144 145 /** Operator for output to std::ostream operator of an std::queue of arbitrary 146 * type. 147 * @param ost output stream 148 * @param _queue queue of types to output 149 * @return ost output stream 150 */ 151 template <class T, class alloc> std::ostream & operator<<(std::ostream &ost, const std::queue< T, alloc > &_queue) 152 { 153 ost << "( "; 154 for (typename std::queue< T, alloc >::const_iterator iter = _queue.begin(); 155 iter != _queue.end(); 156 ++iter) 157 ost << *iter << "; "; 158 ost << ")"; 159 return ost; 160 } 161 80 162 81 163 /** Operator for output to std::ostream operator of an std::set of arbitrary … … 85 167 * @return ost output stream 86 168 */ 87 template <class T> std::ostream & operator<<(std::ostream &ost, const std::set< T > &_vector) 88 { 89 ost << "( "; 90 for (typename std::set< T >::const_iterator iter = _vector.begin(); 91 iter != _vector.end(); 92 ++iter) 93 ost << *iter << "; "; 94 ost << ")"; 95 return ost; 96 } 97 169 template <class T, class comp, class alloc> std::ostream & operator<<(std::ostream &ost, const std::set< T, comp, alloc > &_set) 170 { 171 ost << "( "; 172 for (typename std::set< T, comp, alloc >::const_iterator iter = _set.begin(); 173 iter != _set.end(); 174 ++iter) 175 ost << *iter << "; "; 176 ost << ")"; 177 return ost; 178 } 98 179 99 180 /** Operator for output to std::ostream operator of an std::vector of arbitrary … … 103 184 * @return ost output stream 104 185 */ 105 template <class T > std::ostream & operator<<(std::ostream &ost, const std::vector< T> &_vector)106 { 107 ost << "( "; 108 for (typename std::vector< T >::const_iterator iter = _vector.begin();186 template <class T, class alloc> std::ostream & operator<<(std::ostream &ost, const std::vector< T, alloc > &_vector) 187 { 188 ost << "( "; 189 for (typename std::vector< T, alloc >::const_iterator iter = _vector.begin(); 109 190 iter != _vector.end(); 110 191 ++iter)
Note:
See TracChangeset
for help on using the changeset viewer.
