Hi I have a requirement of using dereferencing pointer, like in the below code
checkSmartPtr.h ============ #include<iostream> #include"test.h" using namespace std; template<class T> class SmartPtr { public: SmartPtr(T *ptr):pointee(ptr) { } T *operator->() { return pointee; } private: T *pointee; }; SmartPtr<Test> make_test() { return SmartPtr<Test>(new Test(5)); } void do_something(SmartPtr<Test> f) { f->display(); } test.h ==== #include<iostream> using namespace std; class Test { public: Test(int i); void display(); int getNum(); private: int x; }; test.cpp ===== #include<iostream> #include"test.h" using namespace std; // a class for testing purpose only(Smart ptr can wrap the object of this class) Test::Test(int i): x(i) { } void Test::display() { cout << "value of x: " << this->x << endl; } int Test::getNum() { return this->x; } Like in cpp I can use the display() function using Test *test = new Test(10); SmartPtr<Test> obj1(test); obj1->display(); How would I use it in python from the binding generated by pyplusplus? When I generate the wrapper for checkSmartPtr.h using pyplusplus Below warnings displayed. Looking at warnings it seems like operator -> is not supported in pyplusplus. ------------- WARNING: Test * SmartPtr<Test>::operator->() [member operator] > compilation error W1014: "operator->" is not supported. See Boost.Python > documentation: > http://www.boost.org/libs/python/doc/v2/operators.html#introduction. WARNING: Test * SmartPtr<Test>::operator->() [member operator] > compilation error W1050: The function returns "Test *" type. You have to > specify a call policies.Be sure to take > a look on Py++ defined call policies: http://language- > binding.net/pyplusplus/documentation/functions/call_policies.html#py-defined-call-policies ---------- If operator -> is not supported then what is the mechanism for using it? -- View this message in context: http://old.nabble.com/How-to-make-use-of--%3E-%28dereferncing%29-operator-in-pyplusplus-tp28239246p28239246.html Sent from the Python - c++-sig mailing list archive at Nabble.com. _______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig