AdditionalObjectDeleter.hpp
Go to the documentation of this file.
1  /*
2  Copyright 2015 Dr. Blatt - HPC-Simulation-Software & Services
3  Copyright 2015 Statoil AS
4 
5  This file is part of the Open Porous Media project (OPM).
6 
7  OPM is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  OPM is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with OPM. If not, see <http://www.gnu.org/licenses/>.
19 */
20 #ifndef OPM_ADDITIONALOBJECTDELETER_HEADER_INCLUDED
21 #define OPM_ADDITIONALOBJECTDELETER_HEADER_INCLUDED
22 namespace Opm
23 {
35 template<class T>
37 {
38 public:
41  : additional_object_()
42  {}
44  AdditionalObjectDeleter(T& additional_object)
45  : additional_object_(&additional_object){}
47  template<class T1>
48  void operator()(T1* pt)
49  {
50  delete pt;
51  delete additional_object_;
52  }
53 private:
54  T* additional_object_;
55 };
56 
57 }
58 #endif
Definition: AdditionalObjectDeleter.hpp:22
A custom deleter that will delete an additional object, too.
Definition: AdditionalObjectDeleter.hpp:36
void operator()(T1 *pt)
Delete an object and the additional one.
Definition: AdditionalObjectDeleter.hpp:48
AdditionalObjectDeleter(T &additional_object)
Constructor taking the object that needs to deleted.
Definition: AdditionalObjectDeleter.hpp:44
AdditionalObjectDeleter()
empty constructor.
Definition: AdditionalObjectDeleter.hpp:40