Dune Core Modules (2.4.1)

shared_ptr.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_SHARED_PTR_HH
5 #define DUNE_SHARED_PTR_HH
6 
7 #include <memory>
8 
9 #include <dune/common/nullptr.hh>
17 namespace Dune
18 {
19  // pull in default implementations
20  using std::shared_ptr;
21  using std::make_shared;
22 
51  template<class T>
52  struct null_deleter
53  {
54  void operator() (T*) const {}
55  };
56 
75  template<typename T>
76  inline shared_ptr<T> stackobject_to_shared_ptr(T & t)
77  {
78  return shared_ptr<T>(&t, null_deleter<T>());
79  }
80 
104  template<typename T, typename T2>
105  inline shared_ptr<T2> stackobject_to_shared_ptr(T & t)
106  {
107  return shared_ptr<T2>(dynamic_cast<T2*>(&t), null_deleter<T2>());
108  }
109 
110 }
111 #endif
Dune namespace.
Definition: alignment.hh:10
Fallback implementation of the nullptr object in C++0x.
implements the Deleter concept of shared_ptr without deleting anything
Definition: shared_ptr.hh:53
shared_ptr< T2 > stackobject_to_shared_ptr(T &t)
Create a shared_ptr to a base class for a stack-allocated object.
Definition: shared_ptr.hh:105
shared_ptr< T > stackobject_to_shared_ptr(T &t)
Create a shared_ptr for a stack-allocated object.
Definition: shared_ptr.hh:76
Traits for type conversions and type information.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.80.0 (May 9, 22:29, 2024)