Re: [Boost-bugs] [Boost C++ Libraries] #6203: boost::python::api::object constructor failure

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #6203: boost::python::api::object constructor failure
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-12-04 04:00:18


#6203: boost::python::api::object constructor failure
------------------------------------------------+---------------------------
  Reporter: Johan RÃ¥de <johan.rade@…> | Owner: rwgk
      Type: Bugs | Status: closed
 Milestone: To Be Determined | Component: Python
   Version: Boost 1.48.0 | Severity: Problem
Resolution: invalid | Keywords:
------------------------------------------------+---------------------------
Changes (by rwgk):

  * status: new => closed
  * resolution: => invalid

Comment:

 This is not a bug. Construction of boost::python::object from a raw
 pointer is not supported. Try this (didn't try to compile this, but I
 tested the idea):

 {{{
 boost::python::object create(char c)
 {
     if(c == 'X')
         return boost::python::object(boost::shared_ptr<X>(new X));
     else if(c == 'Y')
         return boost::python::object(boost::shared_ptr<Y>(new Y));
     else if(c == 'Z')
         return boost::python::object(boost::shared_ptr<Z>(new Z));
     else
         throw std::exception("The function argument must be 'X', 'Y' or
 'Z'.");
 }
 }}}

 with

 {{{
     class_<X, boost::shared_ptr<X>, noncopyable>("X").def("hello",
 &X::hello);

 }}}


 etc.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/6203#comment:2>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:07 UTC