From 62483525bb81a62b72539a3bda9d1a9b425b482c Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Sun, 19 Jan 2020 15:41:23 +0000 Subject: Move DeleteZero to stdalgo::delete_zero. --- include/stdalgo.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'include') diff --git a/include/stdalgo.h b/include/stdalgo.h index 683b2655b..578618132 100644 --- a/include/stdalgo.h +++ b/include/stdalgo.h @@ -182,6 +182,17 @@ namespace stdalgo std::for_each(cont.begin(), cont.end(), defaultdeleter()); } + /** 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 + 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 -- cgit v1.2.3