mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-12-28 03:37:59 +00:00
ENH: Enum class as drop-in alternative for NamedEnum
- the NamedEnum wrapper is somewhate too rigid.
* All enumerated values are contiguous, starting as zero.
* The implicit one-to-one mapping precludes using it for aliases.
* For example, perhaps we want to support alternative lookup names for an
enumeration, or manage an enumeration lookup for a sub-range.
This commit is contained in:
@ -42,13 +42,44 @@ Description
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
void infoHashString
|
||||
(
|
||||
unsigned modulus,
|
||||
std::initializer_list<std::string> lst
|
||||
)
|
||||
{
|
||||
if (modulus)
|
||||
{
|
||||
Info<< "basic string hashing (mod " << label(modulus) << ")" << endl;
|
||||
|
||||
for (const auto& str : lst)
|
||||
{
|
||||
Info<<"hash(" << str.c_str() << ")="
|
||||
<< (Hash<string>()(str) % modulus) << nl;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "basic string hashing" << nl;
|
||||
|
||||
for (const auto& str : lst)
|
||||
{
|
||||
Info<<"hash(" << str.c_str() << ")="
|
||||
<< Hash<string>()(str) << nl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
IFstream is("hashingTests");
|
||||
infoHashString(8, {"asdathis1", "adsxf", "hij", "klmpq"});
|
||||
|
||||
IFstream is("hashingTests");
|
||||
|
||||
while (is.good())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user