AMTypeID - unique integral id for an every typeUseful for example for implementing variant types. You may have union of multiple types and tag with stored type.
Usage
Typical usage is very simple...
uint64_t sw = AMCETypeID<uint64_t>::id();
switch(sw) {
case AMCETypeID<uint32_t>::id(): FAIL() << "Switch: bad branch selected";break;
case AMCETypeID<int64_t>::id(): FAIL() << "Switch: bad branch selected";break;
case AMCETypeID<uint64_t>::id(): ;break;
case AMCETypeID<char*>::id(): FAIL() << "Switch: bad branch selected";break;
case AMCETypeID<std::string>::id(): FAIL() << "Switch: bad branch selected";break;
}
If you dislike long range of hash, you may put its own id by:
Sources
Download at GitHUB
Building AMTypeID
Getting sources
Compiling
mkdir cmake-build-debug
cd cmake-build-debug
cmake ..
make
Output Library
Single test (not necessary)
./TEST_AMTypeID
./TEST_AMTypeID_collect
License
This library is under GNU GPL v3 license. If you need business license, don't hesitate to contact me.
Contribute
Please contact me.
Dependencies