Commit f4fb7904 authored by Christophe Gonzales's avatar Christophe Gonzales

fix cast error in hashFunc of instantiations that appears with mingw on Windows

parent cbb269b6
Pipeline #23232280 passed with stages
in 64 minutes 1 second
......@@ -33,6 +33,11 @@
namespace gum {
// the object that casts correctly the discrete variable sequences
// within the hash table of instantiations
typename HashFuncCastKey< const DiscreteVariable* >::type
HashFunc< Instantiation >::__caster;
// Default constructor
Instantiation::Instantiation() : __master(nullptr), __overflow(false) {
GUM_CONSTRUCTOR(Instantiation);
......
......@@ -1241,7 +1241,9 @@ namespace gum {
* @ingroup hashfunctions_group
*/
template <>
class HashFunc< Instantiation > : public HashFuncBase< Instantiation > {
//class HashFunc< Instantiation > : public HashFuncBase< Instantiation > {
class HashFunc< Instantiation > :
public HashFunc<Size> {
public:
/**
* @brief Computes the hashed value of a key.
......@@ -1249,6 +1251,9 @@ namespace gum {
* @return Returns the hashed value of a key.
*/
Size operator()(const Instantiation& key) const;
private:
static typename HashFuncCastKey< const DiscreteVariable* >::type __caster;
};
} /* namespace gum */
......
......@@ -808,11 +808,11 @@ namespace gum {
INLINE Size HashFunc< Instantiation >::
operator()(const Instantiation& key) const {
Size h = 0;
for (const auto& k :
for (const auto k :
key.variablesSequence()) // k are unique only by address (not by name)
h += Size(k) * key.val(*k);
h += __caster.castToSize(k) * (Size) key.val(*k);
return ((h * HashFuncConst::gold) & this->_hash_mask);
return HashFunc<Size>::operator() ( h );
}
INLINE bool Instantiation::operator==(const Instantiation& other) const {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment