No, I compiled boost.python with just ' --with-python '. and I just made a last try to change the 'shared_ptr<A> const& ' to 'shared_ptr<A>&', and things suddenly become right. ^_^ well I don't quite understand what's going on inside though. maybe 'shared_ptr<A> const&' made temp copy (?) ---------------------------------------------------------------------------- struct A { A() { cerr << "Creating A" << endl; } };
class B { private: // shared_ptr<A> const& m_ptr; //remove const shared_ptr<A> & m_ptr public: //B(shared_ptr<A> const& ptr):m_ptr(ptr) B(shared_ptr<A> & ptr) : m_ptr(ptr) { cerr << "Creating B" << endl; cerr << m_ptr.get() << endl; } void ShowPtr() const { cout << m_ptr.get() << endl; } }; BOOST_PYTHON_MODULE(TryIt) { // class_<B, auto_ptr<B> >("B", init<shared_ptr<A> const&>()) class_<B, auto_ptr<B> >("B", init<shared_ptr<A> &() ) .def("ShowPtr", &B::ShowPtr); class_<A, shared_ptr<A>, noncopyable >("A"); } ---------------------------------------------------- from TryIt import * a = A() # Creating A b = B(a) # Creating B, 0xABCDE b.ShowPtr() # 0xABCDE On Fri, Mar 13, 2009 at 5:57 AM, David Abrahams <d...@boostpro.com> wrote: > > on Thu Mar 12 2009, ZaeX <zaexage-AT-gmail.com> wrote: > > > I just built the boost.python 1.36 with Python2.6.1 and tried again, and > it > > still turned out to be 0xcccccccc in debug build. > > Have you read > > http://www.boost.org/doc/libs/1_38_0/libs/python/doc/building.html#python-debugging-builds > ? > > -- > Dave Abrahams > BoostPro Computing > http://www.boostpro.com > _______________________________________________ > Cplusplus-sig mailing list > Cplusplus-sig@python.org > http://mail.python.org/mailman/listinfo/cplusplus-sig > -- Time is mana, we must hurry
_______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig