diff options
author | Tim King <taking@cs.nyu.edu> | 2017-07-20 17:04:30 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-20 17:04:30 -0700 |
commit | 8b0659e6cd342ae40b676781b5e819d5fd2b3af7 (patch) | |
tree | 5ac55f64d115b3e8865ce8f691f38da65fc82a94 /src/util | |
parent | 6d82ee2d1f84065ff4a86f688a3b671b85728f80 (diff) |
Moving from the gnu extensions for hash maps to the c++11 hash maps
* Replacing __gnu_cxx::hash_map with std::unordered_map.
* Replacing __gnu_cxx::hash_set with std::unordered_set.
* Replacing __gnu_cxx::hash with std::hash.
* Adding missing includes.
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/cache.h | 6 | ||||
-rw-r--r-- | src/util/hash.h | 19 | ||||
-rw-r--r-- | src/util/hash.i | 2 | ||||
-rw-r--r-- | src/util/proof.h | 4 | ||||
-rw-r--r-- | src/util/regexp.cpp | 1 | ||||
-rw-r--r-- | src/util/regexp.h | 10 |
6 files changed, 17 insertions, 25 deletions
diff --git a/src/util/cache.h b/src/util/cache.h index 6f5bac8eb..38dc0fc99 100644 --- a/src/util/cache.h +++ b/src/util/cache.h @@ -21,8 +21,10 @@ #ifndef __CVC4__CACHE_H #define __CVC4__CACHE_H -#include <utility> #include <functional> +#include <unordered_map> +#include <utility> +#include <vector> namespace CVC4 { @@ -33,7 +35,7 @@ namespace CVC4 { */ template <class T, class U, class Hasher = std::hash<T> > class Cache { - typedef std::hash_map<T, U, Hasher> Map; + typedef std::unordered_map<T, U, Hasher> Map; Map d_map; std::vector<T> d_current; typename Map::iterator d_result; diff --git a/src/util/hash.h b/src/util/hash.h index af468e25b..b04fb8bb5 100644 --- a/src/util/hash.h +++ b/src/util/hash.h @@ -20,13 +20,10 @@ #ifndef __CVC4__HASH_H #define __CVC4__HASH_H -// in case it's not been declared as a namespace yet -namespace __gnu_cxx {} +#include <functional> +#include <string> -#include <ext/hash_map> -#include <ext/hash_set> - -namespace __gnu_cxx { +namespace std { #ifdef CVC4_NEED_HASH_UINT64_T // on some versions and architectures of GNU C++, we need a @@ -39,18 +36,10 @@ struct hash<uint64_t> { };/* struct hash<uint64_t> */ #endif /* CVC4_NEED_HASH_UINT64_T */ -}/* __gnu_cxx namespace */ - -// hackish: treat hash stuff as if it were in std namespace -namespace std { using namespace __gnu_cxx; } +}/* std namespace */ namespace CVC4 { -struct StringHashFunction { - size_t operator()(const std::string& str) const { - return __gnu_cxx::hash<const char*>()(str.c_str()); - } -};/* struct StringHashFunction */ template <class T, class U, class HashT = std::hash<T>, class HashU = std::hash<U> > struct PairHashFunction { diff --git a/src/util/hash.i b/src/util/hash.i index 470447fc3..f2f1e6652 100644 --- a/src/util/hash.i +++ b/src/util/hash.i @@ -2,6 +2,4 @@ #include "util/hash.h" %} -%rename(apply) CVC4::StringHashFunction::operator()(const std::string&) const; - %include "util/hash.h" diff --git a/src/util/proof.h b/src/util/proof.h index af68efa97..b34e4aed9 100644 --- a/src/util/proof.h +++ b/src/util/proof.h @@ -21,7 +21,7 @@ #define __CVC4__PROOF_H #include <iosfwd> -#include <ext/hash_map> +#include <unordered_map> namespace CVC4 { @@ -29,7 +29,7 @@ class Expr; class ProofLetCount; struct ExprHashFunction; -typedef __gnu_cxx::hash_map<Expr, ProofLetCount, ExprHashFunction> ProofLetMap; +typedef std::unordered_map<Expr, ProofLetCount, ExprHashFunction> ProofLetMap; class CVC4_PUBLIC Proof { public: diff --git a/src/util/regexp.cpp b/src/util/regexp.cpp index 9915d480d..c32b42bad 100644 --- a/src/util/regexp.cpp +++ b/src/util/regexp.cpp @@ -17,6 +17,7 @@ #include "util/regexp.h" +#include <algorithm> #include <iomanip> #include <iostream> diff --git a/src/util/regexp.h b/src/util/regexp.h index beb0ee097..e7c8c5806 100644 --- a/src/util/regexp.h +++ b/src/util/regexp.h @@ -20,11 +20,13 @@ #ifndef __CVC4__REGEXP_H #define __CVC4__REGEXP_H -#include <vector> -#include <string> +#include <algorithm> +#include <cassert> +#include <functional> #include <set> #include <sstream> -#include <cassert> +#include <string> +#include <vector> #include "base/exception.h" #include "util/hash.h" @@ -333,7 +335,7 @@ namespace strings { struct CVC4_PUBLIC StringHashFunction { size_t operator()(const ::CVC4::String& s) const { - return __gnu_cxx::hash<const char*>()(s.toString().c_str()); + return std::hash<std::string>()(s.toString()); } };/* struct StringHashFunction */ |