yat  0.21pre
Deleter.h
1 #ifndef _theplu_yat_utility_deleter
2 #define _theplu_yat_utility_deleter
3 
4 // $Id: Deleter.h 4089 2021-09-07 00:56:40Z peter $
5 
6 /*
7  Copyright (C) 2012, 2021 Peter Johansson
8 
9  This file is part of the yat library, http://dev.thep.lu.se/yat
10 
11  The yat library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU General Public License as
13  published by the Free Software Foundation; either version 3 of the
14  License, or (at your option) any later version.
15 
16  The yat library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with yat. If not, see <http://www.gnu.org/licenses/>.
23 */
24 
25 #include <new> // for delete operator
26 
27 namespace theplu {
28 namespace yat {
29 namespace utility {
30 
42  class Deleter
43  {
44  public:
51  Deleter(bool active=true);
52 
56  bool active(void) const;
57 
61  template<typename T>
62  void operator()(T* ptr) const
63  {
64  if (active_)
65  delete ptr;
66  }
67 
68  private:
69  bool active_;
70  };
71 
72 }}} // of namespace utility, yat, and theplu
73 
74 #endif
Deleter(bool active=true)
constructor
The Department of Theoretical Physics namespace as we define it.
Functor that deletes an object.
Definition: Deleter.h:42
void operator()(T *ptr) const
Definition: Deleter.h:62

Generated on Wed Jan 25 2023 03:34:29 for yat by  doxygen 1.8.14