Mana
Loading...
Searching...
No Matches
src
utils
dtor.h
Go to the documentation of this file.
1
/*
2
* The Mana Client
3
* Copyright (C) 2004-2009 The Mana World Development Team
4
* Copyright (C) 2009-2012 The Mana Developers
5
*
6
* This file is part of The Mana Client.
7
*
8
* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2 of the License, or
11
* any later version.
12
*
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
17
*
18
* You should have received a copy of the GNU General Public License
19
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20
*/
21
22
#pragma once
23
24
#include <algorithm>
25
#include <utility>
26
27
template
<
typename
T>
28
struct
dtor
29
{
30
void
operator()
(T &ptr) {
delete
ptr; }
31
};
32
33
template
<
typename
T1,
typename
T2>
34
struct
dtor
<std::pair<T1, T2>>
35
{
36
void
operator()
(std::pair<T1, T2> &pair) {
delete
pair.second; }
37
};
38
39
template
<
class
Cont>
40
inline
dtor<typename Cont::value_type>
make_dtor
(Cont
const
&)
41
{
42
return
dtor<typename Cont::value_type>
();
43
}
44
45
template
<
typename
Container>
46
inline
void
delete_all
(
Container
&c)
47
{
48
std::for_each(c.begin(), c.end(),
make_dtor
(c));
49
}
Container
A widget container.
Definition
container.h:41
delete_all
void delete_all(Container &c)
Definition
dtor.h:46
make_dtor
dtor< typename Cont::value_type > make_dtor(Cont const &)
Definition
dtor.h:40
dtor< std::pair< T1, T2 > >::operator()
void operator()(std::pair< T1, T2 > &pair)
Definition
dtor.h:36
dtor
Definition
dtor.h:29
dtor::operator()
void operator()(T &ptr)
Definition
dtor.h:30
Generated by
1.9.8