X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=include%2Fstdalgo.h;h=afbd763fb259eca74f9543afdf75f68b17361005;hb=b512f1b9667ca0479d42e771082f3bc8d92c63a2;hp=3cbb8635021e05042ccd4611450567c1ff90983a;hpb=6d9b2bfee07c906699faef4de5ad85787978be3a;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/stdalgo.h b/include/stdalgo.h index 3cbb86350..afbd763fb 100644 --- a/include/stdalgo.h +++ b/include/stdalgo.h @@ -75,4 +75,23 @@ namespace stdalgo delete o; } }; + + /** + * Deleter that adds the item to the cull list, that is, queues it for + * deletion at the end of the current mainloop iteration + */ + struct culldeleter + { + void operator()(classbase* item); + }; + + /** + * Deletes all elements in a container using operator delete + * @param cont The container containing the elements to delete + */ + template class Cont, typename T, typename Alloc> + inline void delete_all(const Cont& cont) + { + std::for_each(cont.begin(), cont.end(), defaultdeleter()); + } }