title: pybind11 - Wrapping overloaded assignment operator?
body: <p>I'm using pybind11 to expose C++ functions to a Python interface. I want to wrap the overloaded assignment operator but don't know how. The documentation and examples provided don't really cover it, at least from what I saw.</p>
  
  <p>Here's a simplified version of what I'm trying to do:</p>
  
  <pre><code>class Num{
    public:
      Num(const double&amp; num) : m_val(num), m_type(Num::Type::e_none){}
  
      Num&amp; operator=(const double&amp; rhs){m_val = rhs;}
  
    private:
      double m_val;
  };
  </code></pre>
  
  <p>And here's the wrapping:</p>
  
  <pre><code>PYBIND11_MODULE(demo, m){
      py::class_&lt;Num&gt;(m, "Num")
          .def(py::init&lt;const double&amp;&gt;())
          // Overloaded assignment operator binding ?
          ;
  }
  </code></pre>
  
  <p>My main concern is preserving Num's data type when assigning it to a float. e.g.:</p>
  
  <pre><code>&gt;&gt;&gt; m = Num(4.5)
  &gt;&gt;&gt; type(m)
  &lt;class 'demo.Num'&gt;
  &gt;&gt;&gt; m = 5.5
  &gt;&gt;&gt; type(m)
  &lt;class 'float'&gt;
  </code></pre>
  
  <p>This is my first time working with C++ extensions and bindings so any insight on what I should do would be great!</p>