SUNphi  1.0
Map.hpp
Go to the documentation of this file.
1 #ifndef _CONTAINERS_MAP_HPP
2 #define _CONTAINERS_MAP_HPP
3 
4 /// \file containers/Map.hpp
5 ///
6 /// \brief Provides a map with char key
7 ///
8 /// Be careful, use it only with static key! The key is actually a
9 /// const char*: the pointing string is not copied, so it must be
10 /// accessible for the whole time needed
11 
12 #ifdef HAVE_CONFIG_H
13  #include "config.hpp"
14 #endif
15 
16 #include <cstring>
17 #include <map>
18 
19 namespace SUNphi
20 {
21  /// Object incapsulating the comparison operator between two c strings
23  {
24  /// Comparison operator
25  bool operator()(const char* first, ///< First element to compare
26  const char* second) ///< Second element to compare
27  const
28  {
29  return
30  strcmp(first,second)<0;
31  }
32  };
33 
34  /// A map which can be safely used with a c-string
35  template <typename T> // Mapped type
36  using MapWithCStrKey=
37  std::map<const char*,T,CStringComparer>;
38 }
39 
40 
41 #endif
Object incapsulating the comparison operator between two c strings.
Definition: Map.hpp:22
bool operator()(const char *first, const char *second) const
Comparison operator.
Definition: Map.hpp:25