~ubuntu-branches/ubuntu/oneiric/codeblocks/oneiric

« back to all changes in this revision

Viewing changes to src/include/safedelete.h

  • Committer: Bazaar Package Importer
  • Author(s): Michael Casadevall
  • Date: 2008-07-17 04:39:23 UTC
  • Revision ID: james.westby@ubuntu.com-20080717043923-gmsy5cwkdjswghkm
Tags: upstream-8.02
ImportĀ upstreamĀ versionĀ 8.02

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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