/*
* InspIRCd -- Internet Relay Chat Daemon
*
- * Copyright (C) 2014 Attila Molnar <attilamolnar@hush.com>
+ * Copyright (C) 2018, 2020 Sadie Powell <sadie@witchery.services>
+ * Copyright (C) 2014, 2016, 2018 Attila Molnar <attilamolnar@hush.com>
*
* This file is part of InspIRCd. InspIRCd is free software: you can
* redistribute it and/or modify it under the terms of the GNU General Public
* Erase a single element from a vector by overwriting it with a copy of the last element,
* which is then removed. This, in contrast to vector::erase(), does not result in all
* elements after the erased element being moved.
+ * Returns nothing, but all iterators, references and pointers to the erased element and the
+ * last element are invalidated
* @param vect Vector to remove the element from
* @param it Iterator to the element to remove
- * @return Nothing, but all iterators, references and pointers to the erased element and the
- * last element are invalidated
*/
template <typename T>
inline void swaperase(typename std::vector<T>& vect, const typename std::vector<T>::iterator& it)
std::for_each(cont.begin(), cont.end(), defaultdeleter<T>());
}
+ /** Deletes a object and zeroes the memory location that pointed to it.
+ * @param pr A reference to the pointer that contains the object to delete.
+ */
+ template<typename T>
+ void delete_zero(T*& pr)
+ {
+ T* p = pr;
+ pr = NULL;
+ delete p;
+ }
+
/**
* Remove an element from a container
* @param cont Container to remove the element from