about summary refs log tree commit diff
path: root/var_lib_genenet_bnw/k-best/src
diff options
context:
space:
mode:
Diffstat (limited to 'var_lib_genenet_bnw/k-best/src')
-rw-r--r--var_lib_genenet_bnw/k-best/src/get_kbest_nets.cc47
1 files changed, 14 insertions, 33 deletions
diff --git a/var_lib_genenet_bnw/k-best/src/get_kbest_nets.cc b/var_lib_genenet_bnw/k-best/src/get_kbest_nets.cc
index 2ee35265..d0911cf0 100644
--- a/var_lib_genenet_bnw/k-best/src/get_kbest_nets.cc
+++ b/var_lib_genenet_bnw/k-best/src/get_kbest_nets.cc
@@ -16,24 +16,13 @@
 
 
 //HR: Add for hash_set
-#if __GNUC__ < 3 && __GNUC__ >= 2 && __GNUC_MINOR__ >= 95
-# include <hash_set>
-# include <functional>
-# define gnu_namespace std
-#elif __GNUC__ >= 3
-# include <ext/hash_set>
-# if __GNUC_MINOR__ == 0
-# include <functional>
-# define gnu_namespace std
-# else
-# include <ext/functional>
-# define gnu_namespace __gnu_cxx
-# endif
-#else
-# include <hash_set.h>
-# include <functional.h>
-# define gnu_namespace std
-#endif
+// Upstream this was a maze of #ifdefs for <hash_set>/<ext/hash_set>, which
+// C++11 and later dropped.  The set is a std::unordered_set with an explicit
+// hasher; naming the hasher (rather than specialising std::hash for a pointer
+// type, which is not allowed) is the whole portability fix.
+#include <unordered_set>
+#include <functional>
+#define gnu_namespace std
 using namespace gnu_namespace;
 #include <set>
 //
@@ -609,21 +598,13 @@ void insert_vec(list<node>* v,node s, int k){
 
 //===================================================================//
 //HR: Add hash_set to store net_set (i.e. (net, score) pair
-namespace gnu_namespace {
-	
-	template<>
+struct net_set_hash {
+	std::hash<unsigned> hasher_ns;
 
-	struct hash<const net_set*> {
-	
-		hash<unsigned> hasher_ns;
-		
-		size_t operator()(const net_set* ns) const {
-			return hasher_ns((unsigned) roundl(- ns->score*10)); // wrong hash function??
-		}
-
-	}; //end of struct
-
-} //end of namespace
+	size_t operator()(const net_set* ns) const {
+		return hasher_ns((unsigned) roundl(- ns->score*10)); // wrong hash function??
+	}
+}; //end of struct
 
 
 
@@ -635,7 +616,7 @@ struct eqNetScore{
 
 
 
-typedef hash_set<const net_set *, hash<const net_set *>, eqNetScore> NetScoreHashSet;
+typedef std::unordered_set<const net_set *, net_set_hash, eqNetScore> NetScoreHashSet;
 
 NetScoreHashSet knets;