title: Static create methods in boost python
body: <p>I am trying to create an object using boost python.  The class definition (pseudocode):</p>
  
  <pre><code>class Awrap : public A, public boost::python::wrapper&lt;A&gt; {
     static std::shared_ptr&lt;A &gt; Create(...) { ... } // inherited from A
  
     virtual double foo(...) override { // overrides pure virtual function in A
            return this-&gt;get_override("foo")(...);
     }
  };
  
  BOOST_PYTHON_MODULE() {
     using namespace boost::python
     class_&lt;Awrap,std::shared_ptr&lt;Awrap&gt;, boost::noncopyable&gt;("A",boost::python::no_init)
       .def("Create",&amp;A::Create).staticmethod("Create")
       .def("foo",pure_virtual(&amp;Awrap::foo));
  
       boost::python::register_ptr_to_python&lt;std::shared_ptr&lt;A&gt; &gt;();
  }
  </code></pre>
  
  <p>The problem is that when I implement the child in python and call the static create method it creates a pointer to Awrap (not the child).  So it cannot find the python-implemented version of "foo".  If I implement foo in the Awrap class instead of the python child it works fine, but I don't want to do this!</p>
  
  <p>Any suggestions?</p>
  
  <p>Thanks!</p>