SST/macro
unordered.h
Go to the documentation of this file.
1 
2 #ifndef SPROCKIT_SPROCKIT_UNORDERED_H_
3 #define SPROCKIT_SPROCKIT_UNORDERED_H_
4 
5 
6 #include <sprockit/spkt_config.h>
7 
8 #if SPKT_HAVE_CPP11
9 
10 #include <unordered_map>
11 template <typename... Args>
12 using spkt_unordered_map = std::unordered_map<Args...>;
13 
14 #include <unordered_set>
15 template <typename... Args>
16 using spkt_unordered_set = std::unordered_set<Args...>;
17 
18 namespace sprockit {
19 struct enum_hash
20 {
21  template <typename T>
22  inline
23  typename std::enable_if<std::is_enum<T>::value, std::size_t>::type
24  operator()(T const value) const {
25  return static_cast<std::size_t>(value);
26  }
27 };
28 }
29 
30 template <typename Key, typename Value>
31 using spkt_enum_map = std::unordered_map<Key, Value, sprockit::enum_hash>;
32 
33 #elif defined(SPKT_HAVE_BOOST)
34 
35 #include <boost/unordered_map.hpp>
36 #define spkt_unordered_map boost::unordered_map
37 
38 #include <boost/unordered_set.hpp>
39 #define spkt_unordered_set boost::unordered_set
40 
41 #elif SPKT_ENABLE_ORDERED_MAP
42 
43 #include <map>
44 #define spkt_unordered_map std::map
45 #define spkt_enum_map std::map
46 #include <set>
47 #define spkt_unordered_set std::set
48 
49 #else
50 
51 #error Configure error - must either have C++11, external boost, order enable ordered maps
52 
53 #endif
54 
55 
56 
57 #endif /* SPROCKIT_SPROCKIT_UNORDERED_H_ */