UnCoVer (Using Coverability for Verification)
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
standard_operators.h
1 /***************************************************************************
2  * Copyright (C) 2014 by Jan Stückrath <jan.stueckrath@uni-due.de> *
3  * *
4  * This program is free software; you can redistribute it and/or modify *
5  * it under the terms of the GNU General Public License as published by *
6  * the Free Software Foundation; either version 2 of the License, or *
7  * (at your option) any later version. *
8  * *
9  * This program is distributed in the hope that it will be useful, *
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12  * GNU General Public License for more details. *
13  * *
14  * You should have received a copy of the GNU General Public License *
15  * along with this program; if not, write to the *
16  * Free Software Foundation, Inc., *
17  * 51 Franklin St, Fifth Floor, Boston, MA 02110, USA *
18  ***************************************************************************/
19 
20 #ifndef STANDARD_OPERATORS_H_
21 #define STANDARD_OPERATORS_H_
22 
23 // WARNING this is not a nice fix, but has to be done because of problems with ADL lookup
24 namespace std {
25 
29  template <typename K, typename V> ostream& operator<<(ostream& ost, unordered_map<K,V> const& mapping) {
30  typename unordered_map<K,V>::const_iterator iter = mapping.cbegin();
31  ost << "(";
32  while(iter != mapping.cend()) {
33  ost << "[" << iter->first << "," << iter->second << "]";
34  ++iter;
35  }
36  ost << ")";
37  return ost;
38  }
39 
43  template <typename T> ostream& operator<<(ostream& ost, vector<T> const& vec) {
44  typename vector<T>::const_iterator iter = vec.cbegin();
45  ost << "(";
46  if(iter != vec.cend()) {
47  ost << *iter;
48  ++iter;
49  }
50  for (; iter != vec.cend(); iter++)
51  {
52  ost << "," << *iter;
53  }
54  ost << ")";
55  return ost;
56  }
57 
61  template <typename T> ostream& operator<<(ostream& ost, unordered_set<T> const& vec) {
62  typename unordered_set<T>::const_iterator iter = vec.cbegin();
63  ost << "(";
64  if(iter != vec.cend()) {
65  ost << *iter;
66  ++iter;
67  }
68  for (; iter != vec.cend(); iter++)
69  {
70  ost << "," << *iter;
71  }
72  ost << ")";
73  return ost;
74  }
75 
79  template <typename T1, typename T2> ostream& operator<<(ostream& ost, pair<T1,T2> const& pair) {
80  ost << "(" << pair.first << "," << pair.second << ")";
81  return ost;
82  }
83 
84 }
85 
86 #endif /* STANDARD_OPERATORS_H_ */