Gromacs  2025.0-dev-20241011-013a99c
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Typedefs | Functions
unique_cptr.h File Reference
#include <cstdlib>
#include <memory>
#include "gromacs/utility/smalloc.h"
+ Include dependency graph for unique_cptr.h:
+ This graph shows which files directly or indirectly include this file:

Description

Declares gmx::unique_cptr and gmx::sfree_guard.

Author
Teemu Murtola teemu.nosp@m..mur.nosp@m.tola@.nosp@m.gmai.nosp@m.l.com

Classes

struct  gmx::functor_wrapper< T, D >
 wrap function into functor to be used as deleter More...
 

Typedefs

template<typename T , void D = sfree_wrapper>
using gmx::unique_cptr = std::unique_ptr< T, functor_wrapper< T, D >>
 unique_ptr which takes function pointer (has to return void) as template argument
 
typedef unique_cptr< void > gmx::sfree_guard
 Simple guard which calls sfree. See unique_cptr for details.
 

Functions

template<class T >
void gmx::free_wrapper (T *p)
 Wrapper of standard library free(), to be used as unique_cptr deleter for memory allocated by malloc, e.g. by an external library such as TNG.
 
template<class T >
void gmx::sfree_wrapper (T *p)
 sfree wrapper to be used as unique_cptr deleter
 
template<typename T , typename D >
std::unique_ptr< T, D > gmx::create_unique_with_deleter (T *t, D d)
 Create unique_ptr with any deleter function or lambda.