openPMD-api
Public Types | Public Member Functions | List of all members
openPMD::UniquePtrWithLambda< T > Class Template Reference

Unique Pointer class that uses a dynamic destructor type. More...

#include <UniquePtr.hpp>

Inheritance diagram for openPMD::UniquePtrWithLambda< T >:
Inheritance graph
[legend]
Collaboration diagram for openPMD::UniquePtrWithLambda< T >:
Collaboration graph
[legend]

Public Types

using T_decayed = std::remove_extent_t< T >
 

Public Member Functions

 UniquePtrWithLambda (UniquePtrWithLambda &&)=default
 
UniquePtrWithLambdaoperator= (UniquePtrWithLambda &&)=default
 
 UniquePtrWithLambda (UniquePtrWithLambda const &)=delete
 
UniquePtrWithLambdaoperator= (UniquePtrWithLambda const &)=delete
 
 UniquePtrWithLambda (std::unique_ptr< T >)
 Conversion constructor from std::unique_ptr<T> with default deleter.
 
template<typename Del >
 UniquePtrWithLambda (std::unique_ptr< T, Del >)
 Conversion constructor from std::unique_ptr<T> with custom deleter. More...
 
 UniquePtrWithLambda (T_decayed *)
 Construct from raw pointer with default deleter.
 
 UniquePtrWithLambda (T_decayed *, std::function< void(T_decayed *)>)
 Construct from raw pointer with custom deleter.
 
template<typename U >
UniquePtrWithLambda< U > static_cast_ () &&
 Like std::static_pointer_cast. More...
 
template<typename U >
UniquePtrWithLambda< U > static_cast_ () &&
 

Detailed Description

template<typename T>
class openPMD::UniquePtrWithLambda< T >

Unique Pointer class that uses a dynamic destructor type.

Unlike std::shared_ptr, std::unique_ptr has a second type parameter for the destructor, in order to have as little runtime overhead as possible over raw pointers. This unique pointer class behaves like a std::unique_ptr with a std::function based deleter type, making it possible to have one single unique_ptr-like class that still enables user to specify custom destruction behavior, e.g. for GPU buffers.

If not specifying a custom deleter explicitly, this class emulates the behavior of a std::unique_ptr with std::default_delete. This also means that array types are supported as expected.

Template Parameters
TThe pointer type, as in std::unique_ptr.

Constructor & Destructor Documentation

◆ UniquePtrWithLambda()

template<typename T >
template<typename Del >
openPMD::UniquePtrWithLambda< T >::UniquePtrWithLambda ( std::unique_ptr< T, Del >  ptr)

Conversion constructor from std::unique_ptr<T> with custom deleter.

Template Parameters
DelCustom deleter type.

Member Function Documentation

◆ static_cast_()

template<typename T >
template<typename U >
UniquePtrWithLambda<U> openPMD::UniquePtrWithLambda< T >::static_cast_ ( ) &&

Like std::static_pointer_cast.

The dynamic destructor type makes this possible to implement in this case.

Template Parameters
UConvert to unique pointer of this type.

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