DUNE-FEM (unstable)

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// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
5
6#ifndef DUNE_SHARED_PTR_HH
7#define DUNE_SHARED_PTR_HH
8
9#include <memory>
10
17namespace Dune
18{
47 template<class T>
49 {
50 void operator() (T*) const {}
51 };
52
71 template<typename T>
72 inline std::shared_ptr<T> stackobject_to_shared_ptr(T & t)
73 {
74 return std::shared_ptr<T>(&t, null_deleter<T>());
75 }
76
77
95 template<class T>
96 auto wrap_or_move(T&& t)
97 {
98 return std::make_shared<std::decay_t<T>>(std::forward<T>(t));
99 }
100
118 template<class T>
119 auto wrap_or_move(T& t)
120 {
122 }
123
124}
125#endif
Dune namespace.
Definition: alignedallocator.hh:13
std::shared_ptr< T > stackobject_to_shared_ptr(T &t)
Create a shared_ptr for a stack-allocated object.
Definition: shared_ptr.hh:72
auto wrap_or_move(T &&t)
Capture R-value reference to shared_ptr.
Definition: shared_ptr.hh:96
implements the Deleter concept of shared_ptr without deleting anything
Definition: shared_ptr.hh:49
std::shared_ptr< T > stackobject_to_shared_ptr(T &t)
Create a shared_ptr for a stack-allocated object.
Definition: shared_ptr.hh:72
Traits for type conversions and type information.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)