A class for holding a region_t of memory owned "uniquely" by its creator - similar to how ::std::unique_ptr
holds a uniquely- owned pointer.
More...
#include <unique_region.hpp>
|
using | parent = region_t |
|
using | deleter_type = Deleter |
|
|
constexpr | unique_region () noexcept=default |
| Default constructor, creates an empty unique_region which owns nothing.
|
|
constexpr | unique_region (::std::nullptr_t) noexcept |
| Act like the default constructor for nullptr_t's.
|
|
| unique_region (region_t region) noexcept |
| Take ownership of an existing region.
|
|
| unique_region (unique_region &&other) noexcept |
| Move constructor.
|
|
| unique_region (const unique_region &)=delete |
|
unique_region & | operator= (const unique_region &)=delete |
| No copy-assignment - that would break our ownership guarantee.
|
|
unique_region & | operator= (unique_region &&other) noexcept |
| A Move-assignment operator, which takes ownership of the other region.
|
|
unique_region & | operator= (::std::nullptr_t) noexcept |
| Reset the unique_region to empty, invoking the deleter if necessary.
|
|
| operator const_region_t () const noexcept |
| No plain dereferencing - as there is no guarantee that any object has been initialized at those locations, nor do we know its type. More...
|
|
region_t | get () const noexcept |
| Return the stored pointer.
|
|
deleter_type | get_deleter () const noexcept |
| Return a deleter of the fixed type (it can't be a reference - we don't keep a deleter object)
|
|
| operator bool () const noexcept |
| Return true if the stored pointer is not null.
|
|
region_t | release () noexcept |
| Release ownership of any stored pointer.
|
|
void | reset (region_t region=region_t{}) |
| Replace the memory region held by this object. More...
|
|
void | swap (unique_region &other) noexcept |
| Exchange the pointer and deleter with another object.
|
|
template<typename Deleter>
class cuda::memory::unique_region< Deleter >
A class for holding a region_t of memory owned "uniquely" by its creator - similar to how ::std::unique_ptr
holds a uniquely- owned pointer.
- Note
- The class is not templated on the element type - since that is quite immaterial to its management (as well as its copying etc.)
- Template Parameters
-
Deleter | Similar to ::std::unique_ptr's Deleter parameter; it needs to be default-constructible and have an operator(). |
- Todo:
- : Should we really expose the region parent class? We could, instead, have a
get()
or region()
method which provides lvalue-ref access to it.
- Todo:
- : Should this be called a
unique_region
, a-la-unique_ptr
? Or perhaps unique_ptr
is a misnomer, and should have been called owned_ptr
(as opposed to shared_ptr
), and regardless, this should be called an owned_region
?
◆ operator const_region_t()
template<typename Deleter >
No plain dereferencing - as there is no guarantee that any object has been initialized at those locations, nor do we know its type.
TODO: Should we support arrow-dereferencing?
◆ reset()
template<typename Deleter >
Replace the memory region held by this object.
- Parameters
-
region | The new region to maintain with unique ownership. |
- Note
- The deleter is invoked on the previously-held region, if one exists.
The documentation for this class was generated from the following file: