DOLFIN
DOLFIN C++ interface
NoDeleter.h
1 // Copyright (C) 2008 Garth N. Wells
2 //
3 // This file is part of DOLFIN.
4 //
5 // DOLFIN is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // DOLFIN is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
17 //
18 // Modified by Martin Alnes, 2008.
19 //
20 // First added: 2008-09-11
21 // Last changed: 2011-01-28
22 
23 #ifndef __NO_DELETER_H
24 #define __NO_DELETER_H
25 
26 #include <memory>
27 
28 namespace dolfin
29 {
30 
32 
33  class NoDeleter
34  {
35  public:
37  void operator() (const void *) {}
38  };
39 
41 
42  template <typename T>
43  std::shared_ptr<T> reference_to_no_delete_pointer(T& r)
44  {
45  return std::shared_ptr<T>(&r, NoDeleter());
46  }
47 
48 }
49 
50 #endif
void operator()(const void *)
Do nothing.
Definition: NoDeleter.h:37
Definition: adapt.h:29
NoDeleter is a customised deleter intended for use with smart pointers.
Definition: NoDeleter.h:33
std::shared_ptr< T > reference_to_no_delete_pointer(T &r)
Helper function to construct shared pointer with NoDeleter with cleaner syntax.
Definition: NoDeleter.h:43