Exposing a class with a constructor containing a nested private class in constructor using Boost Python
<p>I'm new to Boost Python and I'm looking to expose a class that looks like this:        </p>

<pre><code>///Header File structure
class A
{ public:
    A();
    ~A();
    void B();
  private:
    class Impl;
    std::unique_ptr Impl impl_;
};
///Class Implementation
class A::Impl
{
  public:
  void C();    
}
A::A():impl_(new Impl)
{
}
A::~A()
{
}
void A::B()
{
void C();
}
</code></pre>

<p>Can someone suggest how to do it since the current methods I've tried gives errors since Impl is private and also an accessing already deleted function error:</p>

<pre><code>BOOST_PYTHON_MODULE(libA)
 {
class_&lt;A::Impl&gt;("Impl")
  .def("C", &amp;A::Impl::C)
class_&lt;A&gt;("A",init&lt;std::unique_ptr&gt;)
  .def("B", &amp;A::B)
  }
</code></pre>

<p>The whole point of the pimpl idiom is that it's private and completely transparent to the users of the class. You don't expose it.</p>

<p>What you do need to do is make it clear that <code>A</code> isn't copyable:</p>

<pre><code>class_&lt;A, noncopyable&gt;("A", init&lt;&gt;())
    .def("B", &amp;A::B)
;
</code></pre>

python c++ class boost boost-python