mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
COMP: use intptr_t instead of long for hashing pointers
This commit is contained in:
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2004-2010, 2018 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2004-2010, 2018-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2012 OpenFOAM Foundation
|
| Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||||
@ -51,10 +51,10 @@ namespace Foam
|
|||||||
Class Hash Declaration
|
Class Hash Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
template<class PrimitiveType>
|
template<class T>
|
||||||
struct Hash
|
struct Hash
|
||||||
{
|
{
|
||||||
inline unsigned operator()(const PrimitiveType& obj, unsigned seed=0) const
|
inline unsigned operator()(const T& obj, unsigned seed=0) const
|
||||||
{
|
{
|
||||||
return Hasher(&obj, sizeof(obj), seed);
|
return Hasher(&obj, sizeof(obj), seed);
|
||||||
}
|
}
|
||||||
@ -140,19 +140,18 @@ struct Hash<Foam::keyType>
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//- Hash specialization for pointers.
|
//- Hash specialization for pointers, interpret pointer as a integer type.
|
||||||
// Interpret pointer as a long (works for 32-bit and 64-bit pointers).
|
|
||||||
template<>
|
template<>
|
||||||
struct Hash<void*>
|
struct Hash<void*>
|
||||||
{
|
{
|
||||||
inline unsigned operator()(const void* const& obj, unsigned seed) const
|
inline unsigned operator()(const void* const& obj, unsigned seed) const
|
||||||
{
|
{
|
||||||
return Hash<long>()(long(obj), seed);
|
return Hash<intptr_t>()(intptr_t(obj), seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline unsigned operator()(const void* const& obj) const
|
inline unsigned operator()(const void* const& obj) const
|
||||||
{
|
{
|
||||||
return Hash<long>()(long(obj));
|
return Hash<intptr_t>()(intptr_t(obj));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user