G+Smo  23.12.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gismo::memory Namespace Reference

This namespace contains functions related to memory management. More...

Functions

template<class toC , typename from >
unique_ptr< toC > convert_ptr (from p)
 Converts an uPtr p to an uPtr of class toC and gives it back as return value.
 
template<typename T >
std::vector< T * > get_raw (const std::vector< unique_ptr< T > > &cont)
 Takes a vector of smart pointers and returns the corresponding raw pointers.
 
template<typename T >
std::vector< T * > get_raw (const std::vector< shared_ptr< T > > &cont)
 Takes a vector of smart pointers and returns the corresponding raw pointers.
 
template<typename T >
shared_ptr< T > make_shared (T *x)
 
template<typename T >
shared_ptr< T > make_shared_not_owned (const T *x)
 Creates a shared pointer which does not eventually delete the underlying raw pointer. Usefull to refer to objects which should not be destroyed. More...
 
template<typename T >
unique_ptr< T > make_unique (T *x)
 
template<typename T >
void null_deleter (T *)
 Deleter function that does not delete an object pointer.
 
template<typename T >
std::vector< T * > release (std::vector< unique_ptr< T > > &cont)
 Takes a vector of smart pointers, releases them and returns the corresponding raw pointers.
 

Detailed Description

This namespace contains functions related to memory management.

Function Documentation

shared_ptr<T> gismo::memory::make_shared ( T *  x)
inline

Takes a T* and wraps it in a shared_ptr. Useful for avoiding memory leaks.

This has a move semantics: the shared_ptr object takes the ownership.

shared_ptr<T> gismo::memory::make_shared_not_owned ( const T *  x)
inline

Creates a shared pointer which does not eventually delete the underlying raw pointer. Usefull to refer to objects which should not be destroyed.

The caller keeps the ownership.

unique_ptr<T> gismo::memory::make_unique ( T *  x)
inline

Takes a T* and wraps it in an unique_ptr. Useful for one-off function return values to avoid memory leaks.

This has a move semantics: the unique_ptr object takes the ownership.