I am new user of Boost, I tried to use boost::variant first, but in comparison to boost::any performance of boost::variant appears to be around 4 times slower, so settled for boost::any.

 

Also boost::any has cleaner interface but I don’t know how to query current type information for boost::any ?

 

My code looks like following

 

map<unsigned int, boost::any> result_table;

 

result_table[1] = 543.434;

vector<int> vec;

…. Some vec population code;

result_table[2] = vec;

 

Now I need to develop a stringify function for result_table;

 

I can fetch the results back as

boost::any value = result_table[2];

 

But I need to know the type of value, so that I can treat it accordingly to stringify;

I know there exists type_traits, but very limited examples of type_traits is provided on Boost documentation and particularly, I am clueless about how to use type_traits in above context to find out what is the current type returned by result_table[int]

 

Also I want to know if Boost has any Hash map implementation that can be superior in performance compare to regular std::map ??

 

Thanks,

 

 

Piyush