Proton  1.1.1
Make porting easy from Python to C++11
unordered_map.hpp
1 #ifndef PROTON_UNORDERED_MAP_HEADER
2 #define PROTON_UNORDERED_MAP_HEADER
3 
4 #include <unordered_map>
5 #include <iostream>
6 
7 #include "_mapped_type.hpp"
8 
9 namespace proton{
10 
11 namespace detail{
12 
13 template<typename K, typename V, typename H, typename E, typename A>
14 struct has_t<std::unordered_map<K,V,H,E,A> >{
15  template<typename T> static bool result(const std::unordered_map<K,V,H,E,A>& x, T&& v)
16  {
17  return x.find(v)!=x.end();
18  }
19 };
20 
21 } // ns detail
22 
23 /*
24 template <typename K, typename V, typename H, typename E, typename A, typename T>
25 std::unordered_map<K,V,H,E,A>& operator<<(std::unordered_map<K,V,H,E,A>& x,
26  const std::pair<const K, V>& item)
27 {
28  x.insert(item);
29  return x;
30 }
31 */
32 
33 template <typename K, typename V, typename H, typename E, typename A>
34 std::ostream& operator<<(std::ostream& s, const std::unordered_map<K,V,H,E,A>& x)
35 {
36  s << "{";
37  bool first=true;
38  for(auto& t: x){
39  if(first)
40  first=false;
41  else
42  s <<", ";
43  s << t.first << " : "<<t.second;
44  }
45  s << "}";
46  return s;
47 }
48 
49 }
50 
51 #endif // PROTON_UNORDERED_MAP_HEADER