Remove ptid_get_pid
[deliverable/binutils-gdb.git] / gdb / common / gdb_vecs.h
index 141d05e0189a5eb664736461ce89daa45521efe2..8bafd0dd6a42d8e2ed7aaaf3b33354a21322970d 100644 (file)
 
 #include "vec.h"
 
-typedef const char *const_char_ptr;
-
-DEF_VEC_P (const_char_ptr);
-
 /* Split STR, a list of DELIMITER-separated fields, into a char pointer vector.
 
    You may modify the returned strings.  */
@@ -47,6 +43,22 @@ extern void dirnames_to_char_ptr_vec_append
 extern std::vector<gdb::unique_xmalloc_ptr<char>>
   dirnames_to_char_ptr_vec (const char *dirnames);
 
+/* Remove the element pointed by iterator IT from VEC, not preserving the order
+   of the remaining elements.  Return the removed element.  */
+
+template <typename T>
+T
+unordered_remove (std::vector<T> &vec, typename std::vector<T>::iterator it)
+{
+  gdb_assert (it >= vec.begin () && it < vec.end ());
+
+  T removed = std::move (*it);
+  *it = std::move (vec.back ());
+  vec.pop_back ();
+
+  return removed;
+}
+
 /* Remove the element at position IX from VEC, not preserving the order of the
    remaining elements.  Return the removed element.  */
 
@@ -56,11 +68,7 @@ unordered_remove (std::vector<T> &vec, typename std::vector<T>::size_type ix)
 {
   gdb_assert (ix < vec.size ());
 
-  T removed = std::move (vec[ix]);
-  vec[ix] = std::move (vec.back ());
-  vec.pop_back ();
-
-  return removed;
+  return unordered_remove (vec, vec.begin () + ix);
 }
 
 /* Remove the element at position IX from VEC, preserving the order the
This page took 0.02466 seconds and 4 git commands to generate.