I have some code which performs differently depending on the underlying data type. EG:
void *some_data = obtain_data();
int data_type = obtain_data_type();
This is called in C++ a variant type. There are many libraries that do this for you, such as:
But remember that there's a price to pay when using such a library. Things are not most efficient when you use variants, but some times it's necessary, such as when you use OPC/UA protocols.