From f6c21cd8b5030c99a9014a68dc10d11e8c4781e1 Mon Sep 17 00:00:00 2001 From: ilor <kailoran@gmail.com> Date: Fri, 20 May 2011 15:55:38 +0200 Subject: [PATCH] add .get(), __bool__ and __nonzero__ to shared_ptr wrapper to allow testing if the shared_ptr is valid --- swig/boost_shared_ptr.i | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/swig/boost_shared_ptr.i b/swig/boost_shared_ptr.i index 7803b22..6f3ec42 100644 --- a/swig/boost_shared_ptr.i +++ b/swig/boost_shared_ptr.i @@ -14,6 +14,14 @@ namespace boost { shared_ptr(); shared_ptr(T * p); T* operator->(); + T* get(); + +%pythoncode %{ + def __bool__(self): + return self.get() is not None + __nonzero__=__bool__ +%} + private: T * px; int pn; -- GitLab