title: How to boost::any_cast into std::string
body: <p>I have this test snippet</p>
  
  <pre><code>#include &lt;boost/any.hpp&gt;
  #include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;bitset&gt;
  #include &lt;string&gt;
  
  class wrapper {
    int value;
    char character;
    std::string str;
  
  public:
    wrapper(int i, char c, std::string s) {
      value = i;
      character = c;
      str = s;
     }
  
    void get_data(){
      std::cout &lt;&lt; "Value = " &lt;&lt; value &lt;&lt; std::endl;
      std::cout &lt;&lt; "Character = " &lt;&lt; character &lt;&lt; std::endl;
      std::cout &lt;&lt; "String= " &lt;&lt; str &lt;&lt; std::endl;
    }
  };
  
  int main(){
  
     std::vector&lt;boost::any&gt; container;
     container.push_back(10);
     container.push_back(1.4);
     container.push_back("Mayukh");
     container.push_back('A');
     container.push_back(std::bitset&lt;16&gt;(255) );
     wrapper wrap(20, 'M', "Alisha");
     container.push_back(wrap);
  
     std::cout &lt;&lt; boost::any_cast&lt;int&gt;(container[0]) &lt;&lt; std::endl;
     std::cout &lt;&lt; boost::any_cast&lt;double&gt;(container[1]) &lt;&lt; std::endl;
     std::cout &lt;&lt; boost::any_cast&lt;std::string&gt;(container[2]);
     std::cout &lt;&lt; boost::any_cast&lt;char&gt;(container[3]) &lt;&lt; std::endl;
     std::cout &lt;&lt; boost::any_cast&lt;std::bitset&lt;16&gt;&gt;(container[4]);
     auto p = boost::any_cast&lt;wrapper&gt;(container[5]);
     p.get_data();
  
  return 0;
  
  }
  </code></pre>
  
  <p>In this <code>boost::any_cast</code> gives bad_casting exception for <code>std::string</code>. It means for some reason it is not able to typecast <code>boost::any</code> into <code>std::string</code>. While other classes like <code>bitset</code> or my own user defined class is working. Can you please tell me why &amp; a way out of this?</p>