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 &&) noexcept | |
| UniquePtrWithLambda & | operator= (UniquePtrWithLambda &&) noexcept |
| UniquePtrWithLambda (UniquePtrWithLambda const &)=delete | |
| UniquePtrWithLambda & | operator= (UniquePtrWithLambda const &)=delete |
| template<typename bare_unique_ptr, typename SFINAE = std::enable_if_t< std::is_same_v<bare_unique_ptr, std::unique_ptr<T>>>> | |
| UniquePtrWithLambda (bare_unique_ptr) | |
| Conversion constructor from std::unique_ptr<T> with default deleter. | |
| template<typename Del, typename SFINAE = std::enable_if_t< !std::is_same_v<std::unique_ptr<T, Del>, std::unique_ptr<T>>>> | |
| UniquePtrWithLambda (std::unique_ptr< T, Del >) | |
| Conversion constructor from std::unique_ptr<T> with custom deleter. | |
| 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. | |
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 | ( | bare_unique_ptr | stdPtr | ) |
Conversion constructor from std::unique_ptr<T> with default deleter.
| bare_unique_ptr | Equal to std::unique_ptr<T>. Needs to be a template parameter since we cannot instantiate std::unique_ptr<void>. |
| SFINAE | Used to ensure that bare_unique_ptr actually is std::unique_ptr<T>. |
| openPMD::UniquePtrWithLambda< T >::UniquePtrWithLambda | ( | std::unique_ptr< T, Del > | ptr | ) |
Conversion constructor from std::unique_ptr<T> with custom deleter.
| Del | Custom deleter type. |
| SFINAE | Used to not compete with the std::unique_ptr<T> constructor (without custom deleter). |
| 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. |