1:  
   2:  
   3: #include <boost/any.hpp>
   4: #include <iostream>
   5: #include <vector>
   7: #include <string> 
   8:  
   9: using namespace std;
  10: using namespace boost; 
  11:  
  12: void print(boost::any& arr)
  13: {  14:  
  15: if(typeid(string)==arr.type())
  16:  
  17: {  18:  
  19: cout<<any_cast<string>(arr)<<endl;
  20:  
  21: }
  22:  if(typeid(int)==arr.type())
  23:  
  24: {  25:  
  26: cout<<any_cast<int>(arr)<<endl;
  27:  
  28: }
  29:  if(typeid(char)==arr.type())
  30:  
  31: {  32:  
  33: cout<<any_cast<char>(arr)<<endl;
  34:  
  35: }
  36:  if(typeid(double)==arr.type())
  37:  
  38: {  39:  
  40: cout<<any_cast<double>(arr)<<endl;
  41:  
  42: }
  43: } 
  44:  
  45: int main(int argc, char* argv[])
  46: {  47:  
  48: vector<boost::any> any_arr;
  49:  
  50: any_arr.push_back(string("hello"));  51:  
  52: any_arr.push_back(10);
  53:  
  54: any_arr.push_back('a');  55:  
  56: any_arr.push_back(56.0);
  57:  for(int 
  58: i=0;i<any_arr.size();i++)
  59:  
  60: {  61:  
  62: print(any_arr[i]);
  63:  }
  64:  return 
  65: 0;
  66: }