Reference documentation for deal.II version 9.1.1
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
Public Member Functions | List of all members
VectorMemory< VectorType >::Pointer Class Reference

#include <deal.II/lac/vector_memory.h>

Inherits std::unique_ptr< T >.

Public Member Functions

 Pointer ()=default
 
 Pointer (Pointer &&p) noexcept=default
 
Pointeroperator= (Pointer &&p) noexcept=default
 
 Pointer (VectorMemory< VectorType > &mem)
 
 ~Pointer ()=default
 

Detailed Description

template<typename VectorType = ::Vector<double>>
class VectorMemory< VectorType >::Pointer

A class that looks like a pointer for all practical purposes and that upon construction time allocates a vector from a VectorMemory object (or an object of a class derived from VectorMemory) that is passed to the constructor of this class. The destructor then automatically returns the vector's ownership to the same VectorMemory object.

Pointers of this type are therefore safe in the sense that they automatically call VectorMemory::free() when they are destroyed, whether that happens at the end of a code block or because local variables are destroyed during exception unwinding. These kinds of object thus relieve the user from using vector management functions explicitly.

In many senses, this class acts like std::unique_ptr in that it is the unique owner of a chunk of memory that it frees upon destruction. The main differences to std::unique_ptr are (i) that it allocates memory from a memory pool upon construction, and (ii) that the memory is not destroyed using operator delete but returned to the VectorMemory pool.

Author
Guido Kanschat, 2009; Wolfgang Bangerth, 2017.

Definition at line 192 of file vector_memory.h.

Constructor & Destructor Documentation

◆ Pointer() [1/3]

template<typename VectorType = ::Vector<double>>
VectorMemory< VectorType >::Pointer::Pointer ( )
default

Default constructor. This constructor corresponds to a nullptr object that does not own a vector. It can, however, later be assigned another Pointer object via move assignment in which case it will steal the vector owned by the other object (as std::unique_ptr does).

◆ Pointer() [2/3]

template<typename VectorType = ::Vector<double>>
VectorMemory< VectorType >::Pointer::Pointer ( Pointer &&  p)
defaultnoexcept

Move constructor: this creates a new Pointer by stealing the internal data owned by p.

◆ Pointer() [3/3]

template<typename VectorType = ::Vector<double>>
VectorMemory< VectorType >::Pointer::Pointer ( VectorMemory< VectorType > &  mem)

Constructor. This constructor automatically allocates a vector from the given vector memory object mem.

◆ ~Pointer()

template<typename VectorType = ::Vector<double>>
VectorMemory< VectorType >::Pointer::~Pointer ( )
default

Destructor, automatically releasing the vector from the memory #pool.

Member Function Documentation

◆ operator=()

template<typename VectorType = ::Vector<double>>
Pointer& VectorMemory< VectorType >::Pointer::operator= ( Pointer &&  p)
defaultnoexcept

Move operator: this releases the vector owned by the current Pointer and then steals the internal data owned by p.


The documentation for this class was generated from the following file: