Smart pointer that borrows an object from a BExclusiveBorrow owner. More...
Public Member Functions | |
BBorrow () noexcept | |
Create a new smart pointer with no value. | |
BBorrow (BBorrow &&other) noexcept | |
Move constructor. | |
template<typename P > | |
BBorrow (BExclusiveBorrow< P > &owner) | |
Construct a borrowed object from the owner. | |
BBorrow (nullptr_t) noexcept | |
Special constructor that builds an empty borrow object. | |
~BBorrow () | |
Destructor that returns the object to the original owner. | |
bool | HasValue () const noexcept |
Check if the object has a value or is empty. | |
T & | operator* () const |
Dereference operator. | |
T * | operator-> () const |
Dereference operator. | |
BBorrow & | operator= (BBorrow &&other) noexcept |
Move assignment. | |
void | Return () noexcept |
Return object to the owner. | |
Smart pointer that borrows an object from a BExclusiveBorrow owner.
The BBorrow smart pointer is the accompanyment to the BExclusiveBorrow owner object. See the documentation on that template class on how to use the smart pointer pairs to express and enforce exclusive ownership between the owner and the borrower.
Like a BExclusiveBorrow object, a BBorrow object can either have a borrow or be empty. When it is empty, it means the current object is not borrowing anything at that moment. Any calls to access the underlying data will fail in that case.
T | The type of object that is owned by this smart pointer. |
|
inlinenoexcept |
Create a new smart pointer with no value.
|
inlinenoexcept |
Special constructor that builds an empty borrow object.
|
inlineexplicit |
Construct a borrowed object from the owner.
owner | The owner to borrow from. |
BBorrowError | In case the owner already borrowed their object, or in case the owner is an empty object, as you cannot borrow something that is not there. |
T | The type of object for this BBorrow object. |
P | The type of objedt for the BExclusiveBorrow object. This allows you to have different types between the owner and the borrower, with the requirement that a pointer to type P can be cast to a pointer of type T without issue. |
|
inlinenoexcept |
Move constructor.
other | The object to move from. It will be left empty after the move. |
|
inline |
Destructor that returns the object to the original owner.
If the original owner no longer exists, the underlying object will be deleted.
|
inlinenoexcept |
Check if the object has a value or is empty.
|
inline |
Dereference operator.
BBorrowError | When the smart pointer is empty and there is no object to access. |
|
inline |
Dereference operator.
BBorrowError | When the smart pointer is empty and there is no object to access. |
|
inlinenoexcept |
Move assignment.
other | The object to move from. It will be left empty after the move. |
References BPrivate::Network::BBorrow< T >::Return().
|
inlinenoexcept |
Return object to the owner.
The current object will be set to be an empty object after this call. If the object is already empty, this call will not do anything. If the owner no longer exists, the object will be disposed off.
Referenced by BPrivate::Network::BBorrow< T >::operator=().