dune-common
2.6-git
|
An owning pointer wrapper that can be assigned to (smart) pointers. Cannot be copied. Transfers ownership by cast to any (smart) pointer type. Releases the stored pointer on transfer. NOTE: This is an intermediate solution to switch to std::unique_ptr in later releases smoothly. More...
#include <dune/common/to_unique_ptr.hh>
Public Types | |
using | pointer = typename Super::pointer |
Public Member Functions | |
T * | operator-> () |
STL member. More... | |
ToUniquePtr (pointer ptr=pointer()) noexcept | |
Constructor, stores the pointer. More... | |
ToUniquePtr (std::nullptr_t) noexcept | |
Constructor, creates a nullptr More... | |
operator pointer () noexcept | |
Convert to underlying pointer, releases the stored pointer. NOTE: deprecated. More... | |
operator std::unique_ptr< T > () noexcept | |
Convert to unique_ptr, invalidates the stored pointer. More... | |
operator std::shared_ptr< T > () noexcept | |
Convert to shared_ptr, invalidates the stored pointer. More... | |
operator bool () noexcept | |
Checks whether *this owns an object. More... | |
operator bool () const noexcept | |
Checks whether *this owns an object. More... | |
Public Attributes | |
T | ptr |
STL member. More... | |
Related Functions | |
(Note that these are not member functions.) | |
template<class T , class... Args> | |
ToUniquePtr< T > | makeToUnique (Args &&... args) |
Constructs an object of type T and wraps it in a ToUniquePtr,. More... | |
An owning pointer wrapper that can be assigned to (smart) pointers. Cannot be copied. Transfers ownership by cast to any (smart) pointer type. Releases the stored pointer on transfer. NOTE: This is an intermediate solution to switch to std::unique_ptr in later releases smoothly.
Example of usage:
using Dune::ToUniquePtr< T >::pointer = typename Super::pointer |
|
inlinenoexcept |
Constructor, stores the pointer.
|
inlinenoexcept |
Constructor, creates a nullptr
|
inlineexplicitnoexcept |
Checks whether *this owns an object.
|
inlineexplicitnoexcept |
Checks whether *this owns an object.
|
inlinenoexcept |
Convert to underlying pointer, releases the stored pointer. NOTE: deprecated.
|
inlinenoexcept |
Convert to shared_ptr, invalidates the stored pointer.
|
inlinenoexcept |
Convert to unique_ptr, invalidates the stored pointer.
|
inherited |
STL member.
|
related |
Constructs an object of type T and wraps it in a ToUniquePtr,.
|
inherited |
STL member.