openPMD-api
|
Unique Pointer class that uses a dynamic destructor type. More...
#include <UniquePtr.hpp>
Public Types | |
using | T_decayed = std::remove_extent_t< T > |
Public Member Functions | |
UniquePtrWithLambda (UniquePtrWithLambda &&)=default | |
UniquePtrWithLambda & | operator= (UniquePtrWithLambda &&)=default |
UniquePtrWithLambda (UniquePtrWithLambda const &)=delete | |
UniquePtrWithLambda & | operator= (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_ () && |
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.
T | The pointer type, as in std::unique_ptr. |
openPMD::UniquePtrWithLambda< T >::UniquePtrWithLambda | ( | std::unique_ptr< T, Del > | ptr | ) |
Conversion constructor from std::unique_ptr<T> with custom deleter.
Del | Custom deleter type. |
UniquePtrWithLambda<U> openPMD::UniquePtrWithLambda< T >::static_cast_ | ( | ) | && |
Like std::static_pointer_cast.
The dynamic destructor type makes this possible to implement in this case.
U | Convert to unique pointer of this type. |