dune-pdelab  2.7-git
common/utility.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 
4 #ifndef DUNE_PDELAB_COMMON_UTILITY_HH
5 #define DUNE_PDELAB_COMMON_UTILITY_HH
6 
7 #include <memory>
8 
9 namespace Dune {
10  namespace PDELab {
11 
12 
18 
32  template<typename T>
33  std::shared_ptr<T> ensure_shared_ptr(T & t)
34  {
35  return std::shared_ptr<T>(&t, null_deleter<T>());
36  }
37 
38 #ifndef DOXYGEN
39 
40  template<typename T>
41  std::shared_ptr<T> ensure_shared_ptr(T * t)
42  {
43  return std::shared_ptr<T>(t, null_deleter<T>());
44  }
45 
46  template<typename T>
47  std::shared_ptr<T> & ensure_shared_ptr(std::shared_ptr<T> & t)
48  {
49  return t;
50  }
51 
52 #endif // DOXYGEN
53 
55 
56  } // namespace PDELab
57 } //namespace Dune
58 
59 #endif // DUNE_PDELAB_COMMON_UTILITY_HH
Dune
For backward compatibility – Do not use this!
Definition: adaptivity.hh:28
Dune::PDELab::ensure_shared_ptr
std::shared_ptr< T > ensure_shared_ptr(T &t)
Ensures that t is wrapped in a shared_ptr<T>
Definition: common/utility.hh:33