File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ from libcpp.memory cimport shared_ptr
2+ from libcpp.string cimport string as std_string
3+ from cython.operator cimport dereference as deref
4+
5+
6+ cdef class Holder:
7+
8+ cdef shared_ptr[std_string] inst
9+
10+ def __init__ (self , bytes what ):
11+ cdef std_string p = < std_string> what
12+ self .inst = shared_ptr[std_string](new std_string(p))
13+
14+ def count (self ):
15+ return self .inst.use_count()
16+
17+
18+ def getRef (self ):
19+ cdef Holder res = Holder.__new__ (Holder)
20+ res.inst = self .inst
21+ return res
22+
23+ def getCopy (self ):
24+ cdef Holder res = Holder.__new__ (Holder)
25+ res.inst = shared_ptr[std_string](new std_string(deref(self .inst.get())))
26+ return res
27+
28+ def addX (self ):
29+ self .inst.get().push_back(" x" )
30+
31+ def size (self ):
32+ return self .inst.get().size()
You can’t perform that action at this time.
0 commit comments