STYLE: simplify hashing to use struct instead of class

- more consistent with STL practices for function classes.

- string::hash function class now operates on std::string rather
  than Foam::string since we have now avoided inadvertent use of
  string conversion from int in more places.
This commit is contained in:
Mark Olesen
2018-02-09 15:34:59 +01:00
parent 09a6e94073
commit 3e3c97397e
12 changed files with 70 additions and 208 deletions

View File

@ -143,15 +143,14 @@ public:
static const string null;
//- Hashing function class, shared by all the derived classes
class hash
//- Hashing function for string and derived string classes
struct hash
{
public:
hash() = default;
//- Hash for string.
// Uses Foam::string instead of std::string for automatic conversions.
inline unsigned operator()(const string& str, unsigned seed = 0) const;
inline unsigned operator()
(
const std::string& str,
unsigned seed = 0
) const;
};

View File

@ -254,7 +254,7 @@ inline bool Foam::string::operator()(const std::string& text) const
inline unsigned Foam::string::hash::operator()
(
const string& str,
const std::string& str,
unsigned seed
) const
{