Are typeid(type) and typeid(type).name() unique?

For what I know, typeid(type) would return a type_info object, typeid(type).name()
would print the name of the type, the names are depend on compilers. I would
like to build a table by std::map<typeid(type).name(), std::function>.

My questions :
(1) : According to "modern c++ design", the names of typeid(type).name() are not
always unique(most of the time it would be unique),
so it may not a perfect key for std::map.
what about typeid(type)?Thanks

(2) : If I have to use typeid(type) as the key, the best choice I could
think of is using the map of boost::fusion, what would you recommend?

(3) : In my case, we don't need to insert the key and value pairs frequently
but access the value frequently. What kind of containers would you
recommend for instead of std::map or fusion::map? It would be best
if that kind of containers already developed by boost

I would like to use boost::fusion::map rather than std::map, because I don't want to
change the behaviors of the legacy codes for now

Our codes looks like this
1
2
3
if(typeid(T1) == A && typeid(T2) == B) { //do some jobs}
else if(typeid(T1) == C && typeid(T2) == D) {//do some jobs}
//and so on 

I would like to get rid of these if...else loop without changing the results
I would like to use boost::fusion to complete this task, although I am still studying boost::fusion

Meta state machine looks like an optional, but I have to go through boost::mpl and boost::fusion
before I could use it. Besides, it maybe too complicated for some tasks?

Thanks

Last edited on
Topic archived. No new replies allowed.