ARB
Main Page
Namespaces
Classes
Files
File List
File Members
TEMPLATES
Keeper.h
Go to the documentation of this file.
1
// =========================================================== //
2
// //
3
// File : Keeper.h //
4
// Purpose : Keep allocated data until termination //
5
// //
6
// Coded by Ralf Westram (coder@reallysoft.de) in May 2014 //
7
// http://www.arb-home.de/ //
8
// //
9
// =========================================================== //
10
11
#ifndef KEEPER_H
12
#define KEEPER_H
13
14
#ifndef _GLIBCXX_LIST
15
#include <list>
16
#endif
17
18
template
<
typename
T>
19
class
Keeper
{
20
typedef
std::list<T> kept;
21
kept elems;
22
23
void
destroy(
T
elem);
// needs to be declared for custom T
24
25
public
:
26
Keeper
() {}
27
~Keeper
() {
28
for
(
typename
kept::iterator i = elems.begin(); i != elems.end(); ++i) {
29
destroy(*i);
30
}
31
}
32
void
keep
(
T
elem) { elems.push_back(elem); }
33
};
34
35
// predefined specializations:
36
template
<>
inline
void
Keeper<char*>::destroy
(
char
*
s
) { free(s); }
37
38
39
#else
40
#error Keeper.h included twice
41
#endif // KEEPER_H
Keeper::keep
void keep(T elem)
Definition:
Keeper.h:32
Keeper::Keeper
Keeper()
Definition:
Keeper.h:26
Keeper::~Keeper
~Keeper()
Definition:
Keeper.h:27
Keeper
Definition:
Keeper.h:19
T
Definition:
trnsprob.h:20
s
GB_write_int const char s
Definition:
AW_awar.cxx:154
Generated by
1.8.8