Browse Source

Work around buggy list::remove in libc++

rdb 10 years ago
parent
commit
346d04a256
1 changed files with 13 additions and 0 deletions
  1. 13 0
      dtool/src/dtoolbase/plist.h

+ 13 - 0
dtool/src/dtoolbase/plist.h

@@ -49,6 +49,19 @@ public:
   typedef TYPENAME base_class::const_iterator const_iterator;
   typedef TYPENAME base_class::reverse_iterator reverse_iterator;
   typedef TYPENAME base_class::const_reverse_iterator const_reverse_iterator;
+
+  // This exists because libc++'s remove implementation has a bug with
+  // Panda's allocator class.
+  INLINE void remove(const Type &val) {
+    iterator it = this->begin();
+    while (it != this->end()) {
+      if (*it == val) {
+        it = this->erase(it);
+      } else {
+        ++it;
+      }
+    }
+  };
 };
 
 #endif  // USE_STL_ALLOCATOR