DUNE PDELab (2.8)

utility.hh
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
9namespace Dune {
10 namespace PDELab {
11
12
19
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
std::shared_ptr< T > ensure_shared_ptr(T &t)
Ensures that t is wrapped in a shared_ptr<T>
Definition: utility.hh:33
Dune namespace.
Definition: alignedallocator.hh:11
implements the Deleter concept of shared_ptr without deleting anything
Definition: shared_ptr.hh:47
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 22, 23:30, 2024)