@@ -57,7 +57,11 @@ void SortedDictViewIterType<RevIterType>::track(RevIterType it)
5757 }
5858 if (it != this ->sd ->map ->rend ())
5959 {
60- ++it->second .known_referrers ;
60+ FwdIterType it_base = it.base ();
61+ if (it_base != this ->sd ->map ->end ())
62+ {
63+ ++it_base->second .known_referrers ;
64+ }
6165 }
6266 else
6367 {
@@ -68,20 +72,39 @@ void SortedDictViewIterType<RevIterType>::track(RevIterType it)
6872}
6973
7074/* *
71- * Do all the necessary bookkeeping required to stop tracking the given
75+ * Do all the necessary bookkeeping required to stop tracking the given forward
7276 * iterator of the underlying sorted dictionary.
7377 *
7478 * The caller should ensure that this method is called immediately after the
7579 * iterator member is updated.
7680 *
7781 * @param it Previous value of the iterator member.
7882 */
79- template <typename T >
80- void SortedDictViewIterType<T >::untrack(T it)
83+ template <>
84+ void SortedDictViewIterType<FwdIterType >::untrack(FwdIterType it)
8185{
8286 --it->second .known_referrers ;
8387}
8488
89+ /* *
90+ * Do all the necessary bookkeeping required to stop tracking the given reverse
91+ * iterator of the underlying sorted dictionary.
92+ *
93+ * The caller should ensure that this method is called immediately after the
94+ * iterator member is updated.
95+ *
96+ * @param it Previous value of the iterator member.
97+ */
98+ template <>
99+ void SortedDictViewIterType<RevIterType>::untrack(RevIterType it)
100+ {
101+ FwdIterType it_base = it.base ();
102+ if (it_base != this ->sd ->map ->end ())
103+ {
104+ --it_base->second .known_referrers ;
105+ }
106+ }
107+
85108template <typename T>
86109void SortedDictViewIterType<T>::Delete(PyObject* self)
87110{
0 commit comments