Dune Core Modules (2.3.1)
Dune::shared_ptr< T > Class Template Reference
A reference counting smart pointer. More...
#include <dune/common/shared_ptr.hh>
Public Types | |
| typedef T | element_type |
| The data type we are a pointer for. More... | |
Public Member Functions | |
| shared_ptr () | |
| Constructs a new smart pointer and allocates the referenced Object. | |
| template<class T1 > | |
| shared_ptr (T1 *pointer) | |
| Constructs a new smart pointer from a preallocated Object. More... | |
| template<class T1 , class Deleter > | |
| shared_ptr (T1 *pointer, Deleter deleter) | |
| Constructs a new smart pointer from a preallocated Object. More... | |
| template<class T1 > | |
| shared_ptr (const shared_ptr< T1 > &pointer) | |
| Copy constructor. More... | |
| shared_ptr (const shared_ptr &pointer) | |
| Copy constructor. More... | |
| ~shared_ptr () | |
| Destructor. | |
| template<class T1 > | |
| shared_ptr & | operator= (const shared_ptr< T1 > &pointer) |
| Assignment operator. | |
| shared_ptr & | operator= (const shared_ptr &pointer) |
| Assignment operator. | |
| element_type & | operator* () |
| Dereference as object. | |
| element_type * | operator-> () |
| Dereference as pointer. | |
| const element_type & | operator* () const |
| Dereference as const object. | |
| const element_type * | operator-> () const |
| Dereference as const pointer. | |
| element_type * | get () const |
| Access to the raw pointer, if you really want it. | |
| operator bool () const | |
| Checks if shared_ptr manages an object, i.e. whether get() != 0. | |
| void | swap (shared_ptr &other) |
| Swap content of this shared_ptr and another. | |
| void | reset () |
| Decrease the reference count by one and free the memory if the reference count has reached 0. | |
| template<class T1 > | |
| void | reset (T1 *pointer) |
| Detach shared pointer and set it anew for the given pointer. | |
| int | use_count () const |
| The number of shared_ptrs pointing to the object we point to. | |
| operator __unspecified_bool_type () const | |
| Implicit conversion to "bool". | |
Related Functions | |
(Note that these are not member functions.) | |
| template<typename T > | |
| shared_ptr< T > | stackobject_to_shared_ptr (T &t) |
| Convert a stack-allocated object to a shared_ptr: More... | |
| template<typename T , typename T2 > | |
| shared_ptr< T2 > | stackobject_to_shared_ptr (T &t) |
| Convert a stack object to a shared_ptr of a base class. More... | |
Detailed Description
template<class T>
class Dune::shared_ptr< T >
class Dune::shared_ptr< T >
A reference counting smart pointer.
It is designed such that it is usable within a std::vector. The contained object is destroyed only if there are no more references to it.
Member Typedef Documentation
◆ element_type
template<class T >
| typedef T Dune::shared_ptr< T >::element_type |
The data type we are a pointer for.
This has to have a parameterless constructor.
Friends And Related Function Documentation
◆ stackobject_to_shared_ptr() [1/2]
template<typename T >
|
related |
Convert a stack-allocated object to a shared_ptr:
int i = 10;
shared_ptr<int> pi = stackobject_to_shared_ptr(i);
◆ stackobject_to_shared_ptr() [2/2]
template<typename T , typename T2 >
|
related |
Convert a stack object to a shared_ptr of a base class.
class A {};
class B : public A {};
...
B b;
shared_ptr<A> pa = stackobject_to_shared_ptr<A>(b);
The documentation for this class was generated from the following file:
- dune/common/shared_ptr.hh
|
Legal Statements / Impressum |
Hosted by TU Dresden & Uni Heidelberg |
generated with Hugo v0.111.3
(Mar 16, 23:38, 2026)