diff options
author | lloyd <[email protected]> | 2006-07-02 01:26:46 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2006-07-02 01:26:46 +0000 |
commit | 9fc2248a9689dcb1bc43157e4955347c6fd9c996 (patch) | |
tree | 502928fa0c059d743c9fdfb35f245dea801a17a3 /include | |
parent | 4a85275067375f0f08f2d281512f6d7174c6ca0e (diff) |
Add del_fun and delete2nd functions for running deletes
Use for_each + the delete wrappers in libstate.cpp
Diffstat (limited to 'include')
-rw-r--r-- | include/stl_util.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/include/stl_util.h b/include/stl_util.h index f1ffbff52..0ba73a93a 100644 --- a/include/stl_util.h +++ b/include/stl_util.h @@ -51,6 +51,25 @@ inline R search_map(const std::map<K, V>& mapping, const K& key, } /************************************************* +* Function adaptor for delete operation * +*************************************************/ +template<class T> +class del_fun : public std::unary_function<T, void> + { + public: + void operator()(T* ptr) { delete ptr; } + }; + +/************************************************* +* Delete the second half of a pair of objects * +*************************************************/ +template<typename Pair> +void delete2nd(Pair& pair) + { + delete pair.second; + } + +/************************************************* * Insert a key/value pair into a multimap * *************************************************/ template<typename K, typename V> |