Code::Blocks  SVN r11506
safedelete.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Code::Blocks IDE and licensed under the GNU Lesser General Public License, version 3
3  * http://www.gnu.org/licenses/lgpl-3.0.html
4  */
5 
6 #ifndef DELETEFUN
7 #define DELETEFUN
8 
9 #include <map>
10 #include <vector>
11 #include <list>
12 #include <deque>
13 #include <algorithm>
14 
15 struct SeqDelete
16 {
17  template<typename T>inline void operator()(T& p){Delete(p);}
18  template<typename T, typename U>inline void operator()(std::pair<T,U>& p){Delete(p.second);}
19 };
20 template<typename T>inline void Delete(std::vector<T>& s){for_each(s.begin(), s.end(), SeqDelete()); s.clear();}
21 template<typename T>inline void Delete(std::list<T>& s){for_each(s.begin(), s.end(), SeqDelete()); s.clear();}
22 template<typename T>inline void Delete(std::deque<T>& s){for_each(s.begin(), s.end(), SeqDelete()); s.clear();}
23 template<typename T, typename U>inline void Delete(std::map<T, U>& s){for_each(s.begin(), s.end(), SeqDelete()); s.clear();}
24 
25 #endif
void Delete(std::vector< T > &s)
Definition: safedelete.h:20
void operator()(T &p)
Definition: safedelete.h:17
void operator()(std::pair< T, U > &p)
Definition: safedelete.h:18