title: how to solve this problem with a cast of iterator?
body: <p>The compiler (VC8) error is:<br>
  error C2680: 'std::_Tree&lt;_Traits>::iterator' : invalid target type for dynamic_cast
  <br>the source code to simulate the error :<br>
  [EDIT]source fixed now<br></p>
  
  <pre><code>#include &lt;map&gt;
  #include &lt;string&gt;
  
  struct tag_data
  {
      int in;
      int on;
      std::string sn;
  };
  
  class myclass
  {
  private:
      typedef std::map&lt;std::string, tag_data&gt; TypeData; 
      TypeData MapStorage;
      typedef std::map&lt;unsigned long, TypeData::iterator &gt; TypeToThreadIterMapStorage; 
      TypeToThreadIterMapStorage ThreadIterMapStorage;
  
  public:
      bool find( std::string&amp; k) 
      {
          TypeData::const_iterator theData ; 
          theData = MapStorage.find(k);
          //ThreadIterMapStorage [ 0 ] = MapStorage.begin();// this is ok
          ThreadIterMapStorage [ 1 ] = dynamic_cast&lt;TypeData::iterator&gt;(theData); // the error occurs here
          return theData != MapStorage.end();
      }
  
      virtual ~myclass(){}
  };
  
  int _tmain(int argc, _TCHAR* argv[])
  {
      myclass mc;
      return 0;
  }
  </code></pre>