I'm still working on a good solution to my One-Of-A-Type Container Problem -- and upon reflection I think it would be nice to be able to just use something like a std::map<std::type_info, boost::any>
. Unfortunately, std::type_info
does not define an operator<
, and I think it'd be unreasonable for it to define one.
However, it does seem reasonable to define a hash function for it, because you could simply use the singleton address of the std::type_info
object as a reasonable "hash". Therefore, you'd be able to put a std::type_info
into a std::unordered_map
as the key.
Does C++11 provide such a hash function? Would using the memory address of the std::type_info
singleton be a bad hash strategy?
type_info
object. Since there are multiple types in a program, there must be more than onetype_info
object in the program. – Antigua