title: Double checking: passing out internal reference from member function
body: <p>If I have </p>
  
  <pre><code>//test.hpp
  class iA
  {
  public:
    virtual ~iA(){}
    virtual void foo() const = 0;
  };
  
  
  class A1 : public iA
  {
  public:
    virtual ~A1(){}
    A1(){}
    virtual void foo() const;
  };
  
  class A2 : public iA
  {
  public:
    virtual ~A2(){}
    A2(){}
    virtual void foo() const;
  };
  
  class B
  {
  public:
    B(int a);
    B(const std::string&amp; s);
  
    ~B() {if (a_) {delete a_; a_ = 0;}}
  
    const iA&amp; a() const
    {
      return *a_;
    }
  
    void foo() const;
  
  
  private:
    iA* a_;
  };
  </code></pre>
  
  <p>And I wrote the python wrapper below:</p>
  
  <pre><code>struct iAWrap : iA, boost::python::wrapper&lt;iA&gt;
  {
    void foo() const
    {
      this-&gt;get_override("foo");
    }
  };
  
  BOOST_PYTHON_MODULE(libtest)
  {
      using namespace boost::python;
      def("greet", greet);
  
      class_&lt;iAWrap, boost::noncopyable&gt;("iA")
        .def("foo",pure_virtual(&amp;iA::foo))
          ;
  
      class_&lt;B&gt;("B",init&lt;int&gt;())
          .def(init&lt;std::string&gt;())
          .def("foo", &amp;B::foo)
          .def("a", &amp;B::a, return_internal_reference&lt;1&gt;())//line I have a question about
          ;
  }
  </code></pre>
  
  <p>The return_internal_reference&lt;1> binds the lifetime of the A reference returned to the invisible "self" argument of B?</p>