Gromacs  2016.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Member Functions
gmx::scoped_cptr< T, D > Class Template Reference

#include <gromacs/utility/scoped_cptr.h>

Description

template<class T, void D = sfree_wrapper>
class gmx::scoped_cptr< T, D >

Stripped-down version of scoped_ptr that uses sfree() or custom deleter.

Currently only implements some operations; other operations can be added if they become necessary. The presence of a release() method is not strictly according to scoped_ptr design, but makes it easier to make existing C code exception-safe, and does not really warrant a separate class for such a purpose.

This class provides a basic guard/smart pointer for C pointers.

Methods in this class do not throw.

Public Member Functions

 scoped_cptr (T *ptr=NULL)
 Initializes a scoped_cptr that frees ptr on scope exit. More...
 
 ~scoped_cptr ()
 Frees the pointer passed to the constructor.
 
T * get () const
 Returns the stored pointer.
 
 operator bool () const
 Check for non-null pointer in boolean context.
 
void reset (T *ptr)
 Sets the pointer and frees previous pointer if necessary.
 
T * release ()
 Clears the pointer without freeing the memory, and returns the old value.
 

Constructor & Destructor Documentation

template<class T, void D = sfree_wrapper>
gmx::scoped_cptr< T, D >::scoped_cptr ( T *  ptr = NULL)
inlineexplicit

Initializes a scoped_cptr that frees ptr on scope exit.

Parameters
[in]ptrPointer to use for initialization.

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