summaryrefslogtreecommitdiff
path: root/src/tr1_hash_map.h
blob: f7813ae65fc2cfe4f4aa4379b76316378c2a3489 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#pragma once 

// detection and fallback for unordered_map in C++0x
#ifdef __cplusplus
   #ifdef __GNUC__
       #if __GNUC__ >= 4 && __GNUC_MINOR__ >= 3
          #include <unordered_map>
          #define tr1_hash_map std::unordered_map
          #define tr1_hash_map_ismap 0
       #else
          #include <map>
          #define tr1_hash_map std::map
          #define tr1_hash_map_ismap 1
       #endif
   #else
      #include <map>
      #define tr1_hash_map std::map
      #define tr1_hash_map_ismap 1
   #endif

    // detect gcc 4.3 and use unordered map (part of c++0x)
    // unordered map doesn't play nice with _GLIBCXX_DEBUG, just use a map if its enabled.
    #if  defined( __GNUC__ ) and not defined( _GLIBCXX_DEBUG )
        #if __GNUC__ >= 4 && __GNUC_MINOR__ >= 3
           #include <unordered_map>
           #define my_hash_map std::unordered_map
        #else
           #include <ext/hash_map>
           namespace std {
              using namespace __gnu_cxx;
           }
           #define my_hash_map std::hash_map
        #endif
    #else
       #include <map>
       #define my_hash_map std::map
       #define USE_MAP
    #endif

#endif