Dune Core Modules (2.7.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
80
98 template<class T>
99 auto wrap_or_move(T&& t)
100 {
101 return std::make_shared<std::decay_t<T>>(std::forward<T>(t));
102 }
103
121 template<class T>
122 auto wrap_or_move(T& t)
123 {
125 }
126
127}
128#endif
Dune namespace.
Definition: alignedallocator.hh:14
auto wrap_or_move(T &&t)
Capture R-value reference to shared_ptr.
Definition: shared_ptr.hh:99
shared_ptr< T > stackobject_to_shared_ptr(T &t)
Create a shared_ptr for a stack-allocated object.
Definition: shared_ptr.hh:75
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 (Jul 15, 22:36, 2024)