title: How to convert C++ objects to boost::python::object?
body: <p>bp::extract converts bp::object to specific type.
  The question is how to do vice-verse?</p>
  
  <p>Let's presume I have a PointContainer and Point classes.
  I need to have a function with such signature</p>
  
  <pre><code>bp::object get_point(const PointContainer &amp;, const bp::object &amp; input);
  </code></pre>
  
  <p>It should check if input argument is an integer. In that case it returns a reference to Point instance from PointContainer with corresponding index.
  If it is not an integer then function checks if the input is a slice object (ex. mylist[1:10:2]). In that case it returns a copy of PointContainer.</p>
  
  <p>The question is how to convert Point, PointContainer instances to bp::objects?</p>
  
  <p>Some details about mentioned classes</p>
  
  <pre><code>class_&lt;Point&lt;int&gt;&gt;("Point")
      .def("__getitem__", get_point_item)
      .def("__setitem__", set_point_item)
      .def("__len__", get_point_size)
      .def("__str__", print_point)
      .def("__eq__", &amp;Point&lt;int&gt;::operator ==)
      .def("__ne__", &amp;Point&lt;int&gt;::operator !=)
      .def("set_x", &amp;Point&lt;int&gt;::set_x)
      .def("get_x", &amp;Point&lt;int&gt;::get_x)
      .def("set_y", &amp;Point&lt;int&gt;::set_y)
      .def("get_y", &amp;Point&lt;int&gt;::get_y)
  ;
  
  typedef std::vector&lt;Point&lt;int&gt;&gt; PointContainer;
  typedef boost::shared_ptr&lt;PointContainer&gt; PointContainerPtr;
  
  class_&lt;PointContainer, PointContainerPtr&gt;("PointContainer")
      .def("__iter__", iterator&lt;PointContainer&gt;())
      .def("__getitem__", get_point)
      .def("__setitem__", set_point)
      .def("__len__", &amp;PointContainer::size)
      .def("append", push_point)
      .def("reserve", &amp;PointContainer::reserve)
      .def("clear", &amp;PointContainer::clear)
  ;
  </code></pre>