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:
Mark Olesen
2017-05-29 13:13:53 +02:00
parent 77a5b99e92
commit 8afc6cbd86
5 changed files with 640 additions and 3 deletions

View File

@ -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())
{