Mana
Loading...
Searching...
No Matches
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
27template<typename T>
28struct dtor
29{
30 void operator()(T &ptr) { delete ptr; }
31};
32
33template<typename T1, typename T2>
34struct dtor<std::pair<T1, T2>>
35{
36 void operator()(std::pair<T1, T2> &pair) { delete pair.second; }
37};
38
39template<class Cont>
44
45template<typename Container>
46inline void delete_all(Container &c)
47{
48 std::for_each(c.begin(), c.end(), make_dtor(c));
49}
A widget container.
Definition container.h:41
void delete_all(Container &c)
Definition dtor.h:46
dtor< typename Cont::value_type > make_dtor(Cont const &)
Definition dtor.h:40
void operator()(std::pair< T1, T2 > &pair)
Definition dtor.h:36
Definition dtor.h:29
void operator()(T &ptr)
Definition dtor.h:30