Dune Core Modules (2.6.0)

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
16namespace Dune
17{
18 // pull in default implementations
19 using std::shared_ptr;
20 using std::make_shared;
21
50 template<class T>
52 {
53 void operator() (T*) const {}
54 };
55
74 template<typename T>
75 inline shared_ptr<T> stackobject_to_shared_ptr(T & t)
76 {
77 return shared_ptr<T>(&t, null_deleter<T>());
78 }
79
103 template<typename T, typename T2>
104 inline DUNE_DEPRECATED_MSG("Do not use the explicit casting version of stackobject_to_shared_ptr, just assign the result to a shared_ptr to the base class")
105 std::enable_if_t<
106 not std::is_same<T,T2>::value,
107 shared_ptr<T>
108 >
110 {
111 return shared_ptr<T2>(&t, null_deleter<T2>());
112 }
113
114
132 template<class T>
133 auto wrap_or_move(T&& t)
134 {
135 return std::make_shared<std::decay_t<T>>(std::forward<T>(t));
136 }
137
155 template<class T>
156 auto wrap_or_move(T& t)
157 {
159 }
160
161}
162#endif
#define DUNE_DEPRECATED_MSG(text)
Mark some entity as deprecated.
Definition: deprecated.hh:169
Dune namespace.
Definition: alignedallocator.hh:10
auto wrap_or_move(T &&t)
Capture R-value reference to shared_ptr.
Definition: shared_ptr.hh:133
shared_ptr< T > stackobject_to_shared_ptr(T &t)
Create a shared_ptr for a stack-allocated object.
Definition: shared_ptr.hh:75
STL namespace.
implements the Deleter concept of shared_ptr without deleting anything
Definition: shared_ptr.hh:52
shared_ptr< T > stackobject_to_shared_ptr(T &t)
Create a shared_ptr for a stack-allocated object.
Definition: shared_ptr.hh:75
Traits for type conversions and type information.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 26, 23:30, 2024)