title: TypeCasting Map <int, class A> to <int, class B> in C++
body: <p>So I have a function that accepts a map as an argument as follows.</p>
  
  <pre><code>function do_dope_stuff(int arg1, std::map&lt;uint32_t, parent_class&gt;&amp; my_object){
      //do some programmer magic
  }
  </code></pre>
  
  <p>This function is then called from a couple different places where one of the map ID's is of a dervired object type.</p>
  
  <pre><code>do_dope_stuff(int, std::map&lt;uint32_t, child_class1&gt;&amp;) 
  
  or
  
  do_dope_stuff(int, std::map&lt;uint32_t, child_class2&gt;&amp;)
  </code></pre>
  
  <p>Well this obviously doesn't work because there is no matching function call since the maps are of different types. So my essential question is how I can typecast the map to make this work without having to create a copy of this huge map and explicitly convert the individual objects to a compatible type. Because the child_class object can be promoted to the parent class but the compiler doesn't like me trying to use C style casting on the map. I also don't want to change the function prototype or overload this since its used in a huge testbench.</p>