mirror of https://github.com/KLayout/klayout.git
Separating tl::hfunc from std namespace. Needed to support int128 in tl::Variant for 64bit coordinate builds.
This commit is contained in:
parent
561a760881
commit
2668b42d29
|
|
@ -53,7 +53,7 @@ struct ResultCountingInserter
|
|||
{
|
||||
typedef db::Polygon value_type;
|
||||
|
||||
ResultCountingInserter (std::unordered_map<const db::Polygon *, size_t, std::ptr_hash_from_value<db::Polygon> > &result)
|
||||
ResultCountingInserter (std::unordered_map<const db::Polygon *, size_t, tl::ptr_hash_from_value<db::Polygon> > &result)
|
||||
: mp_result (&result)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
|
|
@ -70,7 +70,7 @@ struct ResultCountingInserter
|
|||
}
|
||||
|
||||
private:
|
||||
std::unordered_map<const db::Polygon *, size_t, std::ptr_hash_from_value<db::Polygon> > *mp_result;
|
||||
std::unordered_map<const db::Polygon *, size_t, tl::ptr_hash_from_value<db::Polygon> > *mp_result;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ namespace db
|
|||
* for use with std::unordered_map and std::unordered_set
|
||||
*/
|
||||
|
||||
namespace std
|
||||
namespace tl
|
||||
{
|
||||
inline size_t hfunc_coord (db::DCoord d)
|
||||
{
|
||||
|
|
@ -89,15 +89,6 @@ namespace std
|
|||
return hfunc_coord (o.x (), hfunc_coord (o.y ()));
|
||||
}
|
||||
|
||||
template <class C>
|
||||
struct hash <db::point<C> >
|
||||
{
|
||||
size_t operator() (const db::point<C> &o) const
|
||||
{
|
||||
return hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Hash value for a vector
|
||||
*/
|
||||
|
|
@ -114,15 +105,6 @@ namespace std
|
|||
return hfunc_coord (o.x (), hfunc_coord (o.y ()));
|
||||
}
|
||||
|
||||
template <class C>
|
||||
struct hash <db::vector<C> >
|
||||
{
|
||||
size_t operator() (const db::vector<C> &o) const
|
||||
{
|
||||
return hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Hash value for a box
|
||||
*/
|
||||
|
|
@ -139,15 +121,6 @@ namespace std
|
|||
return hfunc (o.p1 (), hfunc (o.p2 ()));
|
||||
}
|
||||
|
||||
template <class C>
|
||||
struct hash <db::box<C> >
|
||||
{
|
||||
size_t operator() (const db::box<C> &o) const
|
||||
{
|
||||
return hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Hash value for an edge
|
||||
*/
|
||||
|
|
@ -164,15 +137,6 @@ namespace std
|
|||
return hfunc (o.p1 (), hfunc (o.p2 ()));
|
||||
}
|
||||
|
||||
template <class C>
|
||||
struct hash <db::edge<C> >
|
||||
{
|
||||
size_t operator() (const db::edge<C> &o) const
|
||||
{
|
||||
return hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Hash value for an edge pair
|
||||
*/
|
||||
|
|
@ -189,15 +153,6 @@ namespace std
|
|||
return hfunc (o.lesser (), hfunc (o.greater (), hfunc (int (o.is_symmetric ()))));
|
||||
}
|
||||
|
||||
template <class C>
|
||||
struct hash <db::edge_pair<C> >
|
||||
{
|
||||
size_t operator() (const db::edge_pair<C> &o) const
|
||||
{
|
||||
return hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Hash value for a text object
|
||||
*/
|
||||
|
|
@ -220,15 +175,6 @@ namespace std
|
|||
return hfunc (o, size_t (0));
|
||||
}
|
||||
|
||||
template <class C>
|
||||
struct hash <db::text<C> >
|
||||
{
|
||||
size_t operator() (const db::text<C> &o) const
|
||||
{
|
||||
return hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Hash value for a path
|
||||
*/
|
||||
|
|
@ -259,15 +205,6 @@ namespace std
|
|||
return hfunc (o, size_t (0));
|
||||
}
|
||||
|
||||
template <class C>
|
||||
struct hash <db::path<C> >
|
||||
{
|
||||
size_t operator() (const db::path<C> &o) const
|
||||
{
|
||||
return hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Hash value for a polygon contour
|
||||
*/
|
||||
|
|
@ -294,15 +231,6 @@ namespace std
|
|||
return hfunc (o, size_t (0));
|
||||
}
|
||||
|
||||
template <class C>
|
||||
struct hash <db::polygon_contour<C> >
|
||||
{
|
||||
size_t operator() (const db::path<C> &o) const
|
||||
{
|
||||
return hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Hash value for a polygon
|
||||
*/
|
||||
|
|
@ -330,15 +258,6 @@ namespace std
|
|||
return hfunc (o, size_t (0));
|
||||
}
|
||||
|
||||
template <class C>
|
||||
struct hash <db::polygon<C> >
|
||||
{
|
||||
size_t operator() (const db::polygon<C> &o) const
|
||||
{
|
||||
return hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Hash value for a simple polygon
|
||||
*/
|
||||
|
|
@ -355,15 +274,6 @@ namespace std
|
|||
return hfunc (o, size_t (0));
|
||||
}
|
||||
|
||||
template <class C>
|
||||
struct hash <db::simple_polygon<C> >
|
||||
{
|
||||
size_t operator() (const db::simple_polygon<C> &o) const
|
||||
{
|
||||
return hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Hash value for a simple transformation
|
||||
*/
|
||||
|
|
@ -380,15 +290,6 @@ namespace std
|
|||
return hfunc (o, size_t (0));
|
||||
}
|
||||
|
||||
template <class C>
|
||||
struct hash <db::simple_trans<C> >
|
||||
{
|
||||
size_t operator() (const db::simple_trans<C> &o) const
|
||||
{
|
||||
return hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A hash function for a displacement transformation
|
||||
*/
|
||||
|
|
@ -405,15 +306,6 @@ namespace std
|
|||
return hfunc (o, size_t (0));
|
||||
}
|
||||
|
||||
template <class C>
|
||||
struct hash <db::disp_trans<C> >
|
||||
{
|
||||
size_t operator() (const db::disp_trans<C> &o) const
|
||||
{
|
||||
return hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Hash value for a complex transformation
|
||||
*/
|
||||
|
|
@ -434,15 +326,6 @@ namespace std
|
|||
return hfunc (o, size_t (0));
|
||||
}
|
||||
|
||||
template <class I, class F, class R>
|
||||
struct hash <db::complex_trans<I, F, R> >
|
||||
{
|
||||
size_t operator() (const db::complex_trans<I, F, R> &o) const
|
||||
{
|
||||
return hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A hash value for a db::CellInstArray and db::DCellInstArray
|
||||
*/
|
||||
|
|
@ -482,15 +365,6 @@ namespace std
|
|||
return hfunc (o, size_t (0));
|
||||
}
|
||||
|
||||
template <class C>
|
||||
struct hash <db::array <db::CellInst, db::simple_trans<C> > >
|
||||
{
|
||||
size_t operator() (const db::array <db::CellInst, db::simple_trans<C> > &o) const
|
||||
{
|
||||
return hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Hash value for an object with properties
|
||||
*/
|
||||
|
|
@ -507,15 +381,6 @@ namespace std
|
|||
return hfunc ((const O &) o, db::hash_for_properties_id (o.properties_id ()));
|
||||
}
|
||||
|
||||
template <class O>
|
||||
struct hash <db::object_with_properties<O> >
|
||||
{
|
||||
size_t operator() (const db::object_with_properties<O> &o) const
|
||||
{
|
||||
return hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A hash function for a shape reference
|
||||
*/
|
||||
|
|
@ -532,15 +397,6 @@ namespace std
|
|||
return hfunc (*o.ptr (), hfunc (o.trans ()));
|
||||
}
|
||||
|
||||
template <class Shape, class Trans>
|
||||
struct hash <db::shape_ref<Shape, Trans> >
|
||||
{
|
||||
size_t operator() (const db::shape_ref<Shape, Trans> &o) const
|
||||
{
|
||||
return hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A hash function for a polygon reference
|
||||
*/
|
||||
|
|
@ -557,15 +413,6 @@ namespace std
|
|||
return hfunc (*o.ptr (), hfunc (o.trans ()));
|
||||
}
|
||||
|
||||
template <class Shape, class Trans>
|
||||
struct hash <db::polygon_ref<Shape, Trans> >
|
||||
{
|
||||
size_t operator() (const db::polygon_ref<Shape, Trans> &o) const
|
||||
{
|
||||
return hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A hash function for a path reference
|
||||
*/
|
||||
|
|
@ -582,15 +429,6 @@ namespace std
|
|||
return hfunc (*o.ptr (), hfunc (o.trans ()));
|
||||
}
|
||||
|
||||
template <class Shape, class Trans>
|
||||
struct hash <db::path_ref<Shape, Trans> >
|
||||
{
|
||||
size_t operator() (const db::path_ref<Shape, Trans> &o) const
|
||||
{
|
||||
return hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A hash function for a text reference
|
||||
*/
|
||||
|
|
@ -607,15 +445,6 @@ namespace std
|
|||
return hfunc (*o.ptr (), hfunc (o.trans ()));
|
||||
}
|
||||
|
||||
template <class Shape, class Trans>
|
||||
struct hash <db::text_ref<Shape, Trans> >
|
||||
{
|
||||
size_t operator() (const db::text_ref<Shape, Trans> &o) const
|
||||
{
|
||||
return hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A hash value for a db::LayerProperties object
|
||||
*/
|
||||
|
|
@ -637,14 +466,191 @@ namespace std
|
|||
return hfunc (o, size_t (0));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
template <class C>
|
||||
struct hash <db::point<C> >
|
||||
{
|
||||
size_t operator() (const db::point<C> &o) const
|
||||
{
|
||||
return tl::hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
template <class C>
|
||||
struct hash <db::vector<C> >
|
||||
{
|
||||
size_t operator() (const db::vector<C> &o) const
|
||||
{
|
||||
return tl::hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
template <class C>
|
||||
struct hash <db::box<C> >
|
||||
{
|
||||
size_t operator() (const db::box<C> &o) const
|
||||
{
|
||||
return tl::hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
template <class C>
|
||||
struct hash <db::edge<C> >
|
||||
{
|
||||
size_t operator() (const db::edge<C> &o) const
|
||||
{
|
||||
return tl::hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
template <class C>
|
||||
struct hash <db::edge_pair<C> >
|
||||
{
|
||||
size_t operator() (const db::edge_pair<C> &o) const
|
||||
{
|
||||
return tl::hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
template <class C>
|
||||
struct hash <db::text<C> >
|
||||
{
|
||||
size_t operator() (const db::text<C> &o) const
|
||||
{
|
||||
return tl::hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
template <class C>
|
||||
struct hash <db::path<C> >
|
||||
{
|
||||
size_t operator() (const db::path<C> &o) const
|
||||
{
|
||||
return tl::hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
template <class C>
|
||||
struct hash <db::polygon_contour<C> >
|
||||
{
|
||||
size_t operator() (const db::path<C> &o) const
|
||||
{
|
||||
return tl::hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
template <class C>
|
||||
struct hash <db::polygon<C> >
|
||||
{
|
||||
size_t operator() (const db::polygon<C> &o) const
|
||||
{
|
||||
return tl::hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
template <class C>
|
||||
struct hash <db::simple_polygon<C> >
|
||||
{
|
||||
size_t operator() (const db::simple_polygon<C> &o) const
|
||||
{
|
||||
return tl::hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
template <class C>
|
||||
struct hash <db::simple_trans<C> >
|
||||
{
|
||||
size_t operator() (const db::simple_trans<C> &o) const
|
||||
{
|
||||
return tl::hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
template <class C>
|
||||
struct hash <db::disp_trans<C> >
|
||||
{
|
||||
size_t operator() (const db::disp_trans<C> &o) const
|
||||
{
|
||||
return tl::hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
template <class I, class F, class R>
|
||||
struct hash <db::complex_trans<I, F, R> >
|
||||
{
|
||||
size_t operator() (const db::complex_trans<I, F, R> &o) const
|
||||
{
|
||||
return tl::hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
template <class C>
|
||||
struct hash <db::array <db::CellInst, db::simple_trans<C> > >
|
||||
{
|
||||
size_t operator() (const db::array <db::CellInst, db::simple_trans<C> > &o) const
|
||||
{
|
||||
return tl::hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
template <class O>
|
||||
struct hash <db::object_with_properties<O> >
|
||||
{
|
||||
size_t operator() (const db::object_with_properties<O> &o) const
|
||||
{
|
||||
return tl::hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
template <class Shape, class Trans>
|
||||
struct hash <db::shape_ref<Shape, Trans> >
|
||||
{
|
||||
size_t operator() (const db::shape_ref<Shape, Trans> &o) const
|
||||
{
|
||||
return tl::hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
template <class Shape, class Trans>
|
||||
struct hash <db::polygon_ref<Shape, Trans> >
|
||||
{
|
||||
size_t operator() (const db::polygon_ref<Shape, Trans> &o) const
|
||||
{
|
||||
return tl::hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
template <class Shape, class Trans>
|
||||
struct hash <db::path_ref<Shape, Trans> >
|
||||
{
|
||||
size_t operator() (const db::path_ref<Shape, Trans> &o) const
|
||||
{
|
||||
return tl::hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
template <class Shape, class Trans>
|
||||
struct hash <db::text_ref<Shape, Trans> >
|
||||
{
|
||||
size_t operator() (const db::text_ref<Shape, Trans> &o) const
|
||||
{
|
||||
return tl::hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct hash <db::LayerProperties>
|
||||
{
|
||||
size_t operator() (const db::LayerProperties &o) const
|
||||
{
|
||||
return hfunc (o);
|
||||
return tl::hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -296,7 +296,7 @@ PropertiesSet::hash () const
|
|||
tl::MutexLocker locker (&lock);
|
||||
|
||||
if (! m_hash) {
|
||||
m_hash = std::hfunc (to_map ());
|
||||
m_hash = tl::hfunc (to_map ());
|
||||
if (! m_hash) {
|
||||
// avoid 0 value as this is reserved for "not computed yet"
|
||||
m_hash = size_t (1);
|
||||
|
|
|
|||
|
|
@ -867,15 +867,15 @@ size_t
|
|||
Shape::hash_value () const
|
||||
{
|
||||
size_t h = size_t (m_type);
|
||||
h = std::hcombine (h, std::hfunc (m_trans));
|
||||
h = tl::hcombine (h, tl::hfunc (m_trans));
|
||||
|
||||
if (m_stable) {
|
||||
// Use the bytes of the iterator binary pattern (see operator<)
|
||||
for (unsigned int i = 0; i < sizeof (tl::reuse_vector<box_type>::const_iterator); ++i) {
|
||||
h = std::hcombine (h, size_t (m_generic.iter[i]));
|
||||
h = tl::hcombine (h, size_t (m_generic.iter[i]));
|
||||
}
|
||||
} else {
|
||||
h = std::hcombine (h, size_t (m_generic.any));
|
||||
h = tl::hcombine (h, size_t (m_generic.any));
|
||||
}
|
||||
|
||||
return h;
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ struct box_defs
|
|||
|
||||
static size_t hash_value (const C *box)
|
||||
{
|
||||
return std::hfunc (*box);
|
||||
return tl::hfunc (*box);
|
||||
}
|
||||
|
||||
static const C &bbox (const C *box)
|
||||
|
|
|
|||
|
|
@ -448,7 +448,7 @@ struct cell_inst_array_defs
|
|||
|
||||
static size_t hash_value (const C *i)
|
||||
{
|
||||
return std::hfunc (*i);
|
||||
return tl::hfunc (*i);
|
||||
}
|
||||
|
||||
static bool less (const C *i, const C &other)
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ struct edge_defs
|
|||
|
||||
static size_t hash_value (const C *e)
|
||||
{
|
||||
return std::hfunc (*e);
|
||||
return tl::hfunc (*e);
|
||||
}
|
||||
|
||||
static gsi::Methods methods ()
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ struct edge_pair_defs
|
|||
|
||||
static size_t hash_value (const C *ep)
|
||||
{
|
||||
return std::hfunc (*ep);
|
||||
return tl::hfunc (*ep);
|
||||
}
|
||||
|
||||
static gsi::Methods methods ()
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ db::LayerProperties li_from_string (const char *s, bool as_target)
|
|||
static
|
||||
size_t hash_value (const db::LayerProperties *l)
|
||||
{
|
||||
return std::hfunc (*l);
|
||||
return tl::hfunc (*l);
|
||||
}
|
||||
|
||||
static bool log_equal_ext (const db::LayerProperties *lp1, const db::LayerProperties &lp2)
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ struct path_defs
|
|||
|
||||
static size_t hash_value (const C *e)
|
||||
{
|
||||
return std::hfunc (*e);
|
||||
return tl::hfunc (*e);
|
||||
}
|
||||
|
||||
static gsi::Methods methods ()
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ struct point_defs
|
|||
|
||||
static size_t hash_value (const C *pt)
|
||||
{
|
||||
return std::hfunc (*pt);
|
||||
return tl::hfunc (*pt);
|
||||
}
|
||||
|
||||
static C move_d (C *p, const vector_type &d)
|
||||
|
|
|
|||
|
|
@ -275,7 +275,7 @@ struct simple_polygon_defs
|
|||
|
||||
static size_t hash_value (const C *p)
|
||||
{
|
||||
return std::hfunc (*p);
|
||||
return tl::hfunc (*p);
|
||||
}
|
||||
|
||||
static bool touches_box (const C *p, const db::box<coord_type> &box)
|
||||
|
|
@ -1215,7 +1215,7 @@ struct polygon_defs
|
|||
|
||||
static size_t hash_value (const C *p)
|
||||
{
|
||||
return std::hfunc (*p);
|
||||
return tl::hfunc (*p);
|
||||
}
|
||||
|
||||
static bool touches_box (const C *p, const db::box<coord_type> &box)
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ struct text_defs
|
|||
|
||||
static size_t hash_value (const C *box)
|
||||
{
|
||||
return std::hfunc (*box);
|
||||
return tl::hfunc (*box);
|
||||
}
|
||||
|
||||
static gsi::Methods methods ()
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ struct trans_defs
|
|||
|
||||
static size_t hash_value (const C *t)
|
||||
{
|
||||
return std::hfunc (*t);
|
||||
return tl::hfunc (*t);
|
||||
}
|
||||
|
||||
static gsi::Methods methods ()
|
||||
|
|
@ -853,7 +853,7 @@ struct cplx_trans_defs
|
|||
|
||||
static size_t hash_value (const C *t)
|
||||
{
|
||||
return std::hfunc (*t);
|
||||
return tl::hfunc (*t);
|
||||
}
|
||||
|
||||
static gsi::Methods methods ()
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ struct vector_defs
|
|||
|
||||
static size_t hash_value (const C *v)
|
||||
{
|
||||
return std::hfunc (*v);
|
||||
return tl::hfunc (*v);
|
||||
}
|
||||
|
||||
static db::point<coord_type> add_with_point (const C *v, const db::point<coord_type> &p)
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
* for use with std::unordered_map and std::unordered_set
|
||||
*/
|
||||
|
||||
namespace std
|
||||
namespace tl
|
||||
{
|
||||
inline size_t hcombine (size_t h1, size_t h2)
|
||||
{
|
||||
|
|
@ -57,14 +57,14 @@ namespace std
|
|||
template <class T>
|
||||
inline size_t hfunc (const T &t)
|
||||
{
|
||||
hash <T> hf;
|
||||
std::hash <T> hf;
|
||||
return hf (t);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline size_t hfunc (const T &t, size_t h)
|
||||
{
|
||||
hash <T> hf;
|
||||
std::hash <T> hf;
|
||||
return hcombine (h, hf (t));
|
||||
}
|
||||
|
||||
|
|
@ -93,15 +93,6 @@ namespace std
|
|||
return hfunc (o.first, hfunc (o.second));
|
||||
}
|
||||
|
||||
template <class T1, class T2>
|
||||
struct hash <std::pair <T1, T2> >
|
||||
{
|
||||
size_t operator() (const std::pair<T1, T2> &o) const
|
||||
{
|
||||
return hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Generic hash for an unordered set
|
||||
*/
|
||||
|
|
@ -118,15 +109,6 @@ namespace std
|
|||
return hfunc (o, size_t (0));
|
||||
}
|
||||
|
||||
template <class T>
|
||||
struct hash <std::unordered_set <T> >
|
||||
{
|
||||
size_t operator() (const std::unordered_set<T> &o) const
|
||||
{
|
||||
return hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Generic hash for a vector
|
||||
*/
|
||||
|
|
@ -143,15 +125,6 @@ namespace std
|
|||
return hfunc (o, size_t (0));
|
||||
}
|
||||
|
||||
template <class T>
|
||||
struct hash <std::vector <T> >
|
||||
{
|
||||
size_t operator() (const std::vector<T> &o) const
|
||||
{
|
||||
return hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Generic hash for a list
|
||||
*/
|
||||
|
|
@ -168,15 +141,6 @@ namespace std
|
|||
return hfunc (o, size_t (0));
|
||||
}
|
||||
|
||||
template <class T>
|
||||
struct hash <std::list <T> >
|
||||
{
|
||||
size_t operator() (const std::list<T> &o) const
|
||||
{
|
||||
return hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Generic hash for a tl::slist
|
||||
*/
|
||||
|
|
@ -193,15 +157,6 @@ namespace std
|
|||
return hfunc (o, size_t (0));
|
||||
}
|
||||
|
||||
template <class T>
|
||||
struct hash <tl::slist <T> >
|
||||
{
|
||||
size_t operator() (const tl::slist<T> &o) const
|
||||
{
|
||||
return hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Generic hash for an ordered set
|
||||
*/
|
||||
|
|
@ -218,15 +173,6 @@ namespace std
|
|||
return hfunc (o, size_t (0));
|
||||
}
|
||||
|
||||
template <class T>
|
||||
struct hash <std::set <T> >
|
||||
{
|
||||
size_t operator() (const std::set<T> &o) const
|
||||
{
|
||||
return hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Generic hash for std::multiset
|
||||
*/
|
||||
|
|
@ -243,15 +189,6 @@ namespace std
|
|||
return hfunc (o, size_t (0));
|
||||
}
|
||||
|
||||
template <class T>
|
||||
struct hash <std::multiset <T> >
|
||||
{
|
||||
size_t operator() (const std::multiset<T> &o) const
|
||||
{
|
||||
return hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Generic hash for an unordered map
|
||||
*/
|
||||
|
|
@ -271,15 +208,6 @@ namespace std
|
|||
return hfunc (o, size_t (0));
|
||||
}
|
||||
|
||||
template <class T1, class T2>
|
||||
struct hash <std::unordered_map<T1, T2> >
|
||||
{
|
||||
size_t operator() (const std::unordered_map<T1, T2> &o) const
|
||||
{
|
||||
return hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Generic hash for an ordered map
|
||||
*/
|
||||
|
|
@ -299,15 +227,6 @@ namespace std
|
|||
return hfunc (o, size_t (0));
|
||||
}
|
||||
|
||||
template <class T1, class T2>
|
||||
struct hash <std::map<T1, T2> >
|
||||
{
|
||||
size_t operator() (const std::map<T1, T2> &o) const
|
||||
{
|
||||
return hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Generic hash for std::multimap
|
||||
*/
|
||||
|
|
@ -327,15 +246,6 @@ namespace std
|
|||
return hfunc (o, size_t (0));
|
||||
}
|
||||
|
||||
template <class T1, class T2>
|
||||
struct hash <std::multimap<T1, T2> >
|
||||
{
|
||||
size_t operator() (const std::multimap<T1, T2> &o) const
|
||||
{
|
||||
return hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Create a pointer hash from the pointer's value
|
||||
*/
|
||||
|
|
@ -344,7 +254,7 @@ namespace std
|
|||
{
|
||||
size_t operator() (const X *ptr) const
|
||||
{
|
||||
return ptr ? hash<X> () (*ptr) : 0;
|
||||
return ptr ? std::hash<X> () (*ptr) : 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -400,6 +310,117 @@ namespace std
|
|||
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_64BIT_COORD)
|
||||
|
||||
inline size_t hfunc (__int128 v)
|
||||
{
|
||||
return hcombine (hfunc (uint64_t (v)), hfunc (uint64_t (v >> 64)));
|
||||
}
|
||||
|
||||
inline size_t hfunc (__int128 v, size_t h)
|
||||
{
|
||||
return hcombine (hfunc (v), h);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
// provide some missing std::hash implementations based on our tl::hfunc
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
template <class T1, class T2>
|
||||
struct hash <std::pair <T1, T2> >
|
||||
{
|
||||
size_t operator() (const std::pair<T1, T2> &o) const
|
||||
{
|
||||
return tl::hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct hash <std::unordered_set <T> >
|
||||
{
|
||||
size_t operator() (const std::unordered_set<T> &o) const
|
||||
{
|
||||
return tl::hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct hash <std::vector <T> >
|
||||
{
|
||||
size_t operator() (const std::vector<T> &o) const
|
||||
{
|
||||
return tl::hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct hash <std::list <T> >
|
||||
{
|
||||
size_t operator() (const std::list<T> &o) const
|
||||
{
|
||||
return tl::hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct hash <tl::slist <T> >
|
||||
{
|
||||
size_t operator() (const tl::slist<T> &o) const
|
||||
{
|
||||
return tl::hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct hash <std::set <T> >
|
||||
{
|
||||
size_t operator() (const std::set<T> &o) const
|
||||
{
|
||||
return tl::hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct hash <std::multiset <T> >
|
||||
{
|
||||
size_t operator() (const std::multiset<T> &o) const
|
||||
{
|
||||
return tl::hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T1, class T2>
|
||||
struct hash <std::unordered_map<T1, T2> >
|
||||
{
|
||||
size_t operator() (const std::unordered_map<T1, T2> &o) const
|
||||
{
|
||||
return tl::hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T1, class T2>
|
||||
struct hash <std::map<T1, T2> >
|
||||
{
|
||||
size_t operator() (const std::map<T1, T2> &o) const
|
||||
{
|
||||
return tl::hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T1, class T2>
|
||||
struct hash <std::multimap<T1, T2> >
|
||||
{
|
||||
size_t operator() (const std::multimap<T1, T2> &o) const
|
||||
{
|
||||
return tl::hfunc (o);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -992,63 +992,63 @@ Variant::hash () const
|
|||
size_t h = 0;
|
||||
|
||||
if (m_type == t_double) {
|
||||
h = std::hfunc (m_var.m_double);
|
||||
h = tl::hfunc (m_var.m_double);
|
||||
} else if (m_type == t_float) {
|
||||
h = std::hfunc (m_var.m_float);
|
||||
h = tl::hfunc (m_var.m_float);
|
||||
} else if (m_type == t_bool) {
|
||||
h = std::hfunc (m_var.m_bool);
|
||||
h = tl::hfunc (m_var.m_bool);
|
||||
} else if (m_type == t_uchar) {
|
||||
h = std::hfunc (m_var.m_uchar);
|
||||
h = tl::hfunc (m_var.m_uchar);
|
||||
} else if (m_type == t_schar) {
|
||||
h = std::hfunc (m_var.m_schar);
|
||||
h = tl::hfunc (m_var.m_schar);
|
||||
} else if (m_type == t_char) {
|
||||
h = std::hfunc (m_var.m_char);
|
||||
h = tl::hfunc (m_var.m_char);
|
||||
} else if (m_type == t_ushort) {
|
||||
h = std::hfunc (m_var.m_ushort);
|
||||
h = tl::hfunc (m_var.m_ushort);
|
||||
} else if (m_type == t_short) {
|
||||
h = std::hfunc (m_var.m_short);
|
||||
h = tl::hfunc (m_var.m_short);
|
||||
} else if (m_type == t_uint) {
|
||||
h = std::hfunc (m_var.m_uint);
|
||||
h = tl::hfunc (m_var.m_uint);
|
||||
} else if (m_type == t_int) {
|
||||
h = std::hfunc (m_var.m_int);
|
||||
h = tl::hfunc (m_var.m_int);
|
||||
} else if (m_type == t_ulong) {
|
||||
h = std::hfunc (m_var.m_ulong);
|
||||
h = tl::hfunc (m_var.m_ulong);
|
||||
} else if (m_type == t_long) {
|
||||
h = std::hfunc (m_var.m_long);
|
||||
h = tl::hfunc (m_var.m_long);
|
||||
} else if (m_type == t_longlong) {
|
||||
h = std::hfunc (m_var.m_longlong);
|
||||
h = tl::hfunc (m_var.m_longlong);
|
||||
} else if (m_type == t_ulonglong) {
|
||||
h = std::hfunc (m_var.m_ulonglong);
|
||||
h = tl::hfunc (m_var.m_ulonglong);
|
||||
#if defined(HAVE_64BIT_COORD)
|
||||
} else if (m_type == t_int128) {
|
||||
h = std::hfunc (m_var.m_int128);
|
||||
h = tl::hfunc (m_var.m_int128);
|
||||
#endif
|
||||
} else if (m_type == t_id) {
|
||||
h = std::hfunc (m_var.m_id);
|
||||
h = tl::hfunc (m_var.m_id);
|
||||
} else if (m_type == t_bytearray) {
|
||||
h = std::hfunc (*m_var.m_bytearray);
|
||||
h = tl::hfunc (*m_var.m_bytearray);
|
||||
#if defined(HAVE_QT)
|
||||
} else if (m_type == t_qstring) {
|
||||
h = std::hfunc (*m_var.m_qstring);
|
||||
h = tl::hfunc (*m_var.m_qstring);
|
||||
} else if (m_type == t_qbytearray) {
|
||||
h = std::hfunc (*m_var.m_qbytearray);
|
||||
h = tl::hfunc (*m_var.m_qbytearray);
|
||||
#endif
|
||||
} else if (m_type == t_stdstring) {
|
||||
h = std::hfunc (*m_var.m_stdstring);
|
||||
h = tl::hfunc (*m_var.m_stdstring);
|
||||
} else if (m_type == t_string) {
|
||||
for (const char *cp = m_string; *cp; ++cp) {
|
||||
h = std::hfunc (*cp, h);
|
||||
h = tl::hfunc (*cp, h);
|
||||
}
|
||||
} else if (m_type == t_list) {
|
||||
h = std::hfunc (*m_var.m_list);
|
||||
h = tl::hfunc (*m_var.m_list);
|
||||
} else if (m_type == t_array) {
|
||||
h = std::hfunc (*m_var.m_array);
|
||||
h = tl::hfunc (*m_var.m_array);
|
||||
} else if (m_type == t_user) {
|
||||
// NOTE: this involves pointers ...
|
||||
h = std::hfunc (m_var.mp_user.object, std::hfunc (m_var.mp_user.cls, 0));
|
||||
h = tl::hfunc (m_var.mp_user.object, tl::hfunc (m_var.mp_user.cls, 0));
|
||||
} else if (m_type == t_user_ref) {
|
||||
const WeakOrSharedPtr *ptr = reinterpret_cast<const WeakOrSharedPtr *> (m_var.mp_user_ref.ptr);
|
||||
h = std::hfunc (ptr->get (), std::hfunc (m_var.mp_user_ref.cls, 0));
|
||||
h = tl::hfunc (ptr->get (), tl::hfunc (m_var.mp_user_ref.cls, 0));
|
||||
}
|
||||
|
||||
return h;
|
||||
|
|
|
|||
Loading…
Reference in New Issue