Commit 9bddff59 authored by Xavier Thompson's avatar Xavier Thompson

Fix reference-counting of underlying dict in cypclass dict views

parent c17a6cba
...@@ -87,19 +87,53 @@ cdef extern from * nogil: ...@@ -87,19 +87,53 @@ cdef extern from * nogil:
class view_dict class view_dict
{ {
private: private:
dict_t urange; dict_t urange = NULL;
public: public:
using iterator = iterator_t; using iterator = iterator_t;
friend void swap(view_dict & first, view_dict & second)
{
using std::swap;
swap(first.urange, second.urange);
}
view_dict() = default; view_dict() = default;
view_dict(view_dict const & rhs) = default; view_dict(view_dict const & rhs) : urange(rhs.urange)
view_dict(view_dict && rhs) = default; {
view_dict & operator=(view_dict const & rhs) = default; if (urange != NULL)
view_dict & operator=(view_dict && rhs) = default; {
~view_dict() = default; urange->CyObject_INCREF();
}
}
view_dict(view_dict && rhs) : view_dict()
{
swap(*this, rhs);
}
view_dict(dict_t urange) : urange(urange) {} view_dict & operator=(view_dict rhs)
{
swap(*this, rhs);
return *this;
}
~view_dict()
{
if (urange != NULL)
{
urange->CyObject_DECREF();
urange = NULL;
}
}
view_dict(dict_t urange) : urange(urange)
{
if (urange != NULL)
{
urange->CyObject_INCREF();
}
}
iterator begin() const iterator begin() const
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment