Crow  0.3
A C++ microframework for the web
ci_map.h
1 #pragma once
2 
3 #include <boost/algorithm/string/predicate.hpp>
4 #include <boost/functional/hash.hpp>
5 #include <unordered_map>
6 
7 namespace crow
8 {
9  /// Hashing function for ci_map (unordered_multimap).
10  struct ci_hash
11  {
12  size_t operator()(const std::string& key) const
13  {
14  std::size_t seed = 0;
15  std::locale locale;
16 
17  for(auto c : key)
18  {
19  boost::hash_combine(seed, std::toupper(c, locale));
20  }
21 
22  return seed;
23  }
24  };
25 
26  /// Equals function for ci_map (unordered_multimap).
27  struct ci_key_eq
28  {
29  bool operator()(const std::string& l, const std::string& r) const
30  {
31  return boost::iequals(l, r);
32  }
33  };
34 
35  using ci_map = std::unordered_multimap<std::string, std::string, ci_hash, ci_key_eq>;
36 }
crow::ci_key_eq
Equals function for ci_map (unordered_multimap).
Definition: ci_map.h:27
crow::ci_hash
Hashing function for ci_map (unordered_multimap).
Definition: ci_map.h:10