Problem with smart pointers

Discussion in 'Python' started by swell@netcourrier.com, Feb 11, 2006.

  1. Guest

    Hello,
    I use the Boost.Python lib for a couple of weeks now and i am
    facing a pb.
    To sum up i have a small hierarchy of objects and have a factory to
    build concrete object. The pb is i think aroud the auto_ptr object that
    is not correctly managed by my code ( i use version 1.33 )
    I think that the solution is obvious but i can't sort it out. If you
    could have a look at this small test


    struct X
    {
    virtual int fun1() = 0;
    int fun2() { return 2;}
    virtual int fun3() { return -1; }
    };

    struct Y : public X
    {
    int fun1() {return 1;}
    virtual fun3() { return 3; }
    };

    struct FactY
    {
    static std:auto_ptr<X> create() { return std:auto_ptr<X>(new Y());}
    };


    BOOST_PYTHON_MODULE(hello)
    {
    class_<X, boost::noncopyable >("X",no_init);
    class_<Y, boost::python::bases<X> >("Y")
    .def("fun1",&Y::fun1)
    .def("fun2",&Y::fun2)
    .def("fun3",&Y::fun3)
    ;

    class_<FactY>("FactY",no_init)
    .def("create",&FactY::create)
    .staticmethod("create")
    ;
    }

    Many Thx
     
    , Feb 11, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Evan
    Replies:
    1
    Views:
    1,324
    Howard Hinnant
    Jun 23, 2003
  2. Bonzo
    Replies:
    1
    Views:
    423
    Cy Edmunds
    Jul 23, 2003
  3. MotoK
    Replies:
    59
    Views:
    1,863
    Keith Thompson
    Sep 15, 2006
  4. n2xssvv g02gfr12930

    Smart pointers and member function pointers

    n2xssvv g02gfr12930, Nov 26, 2005, in forum: C++
    Replies:
    3
    Views:
    485
    n2xssvv g02gfr12930
    Nov 27, 2005
  5. cerr

    pointers, pointers, pointers...

    cerr, Apr 7, 2011, in forum: C Programming
    Replies:
    12
    Views:
    711
Loading...

Share This Page