title: automatically convert list of pointers to derived class to list of pointers to base class
body: <p>Lets say that I have a base and derived class, and a function that takes an stl vector of pointers to the base class:</p>
  
  <pre><code>class A { public: int x; };
  
  class B : public A { };
  
  void foo(const vector&lt;A*&gt; &amp;va) {
      for (vector&lt;A*&gt;::const_iterator it = va.begin(); it &lt; va.end(); it++)
          cout &lt;&lt; (*it)-&gt;x &lt;&lt; endl;
  }
  </code></pre>
  
  <p>is there any way to pass a list of pointers to the derived class? ie:</p>
  
  <pre><code>vector&lt;B*&gt; vb;
  // ... add pointers to vb ...
  foo(vb);
  </code></pre>
  
  <p>The above will cause the following compiler error:</p>
  
  <pre><code>error: could not convert ‘vb’ from ‘std::vector&lt;B*&gt;’ to ‘std::vector&lt;A*&gt;’
  </code></pre>
  
  <p>Even though B* is convertible to A*.</p>
  
  <p>Finally, if there is a solution for plain pointers, will it work with boost shared pointers as well?</p>