Bond 0.9
C++ Bond Runtime Library API Documentation
Loading...
Searching...
No Matches
Bond::Allocator::ObjectHandle< T > Class Template Reference

An owning object handle that derives from unique_ptr that destroys an object using an ObjectDeallocator rather than std::default_delete when it goes out of scope. More...

#include <bond/systems/allocator.h>

Inheritance diagram for Bond::Allocator::ObjectHandle< T >:

Public Member Functions

 ObjectHandle (Allocator *allocator=nullptr, T *ptr=nullptr)
 Constructs an ObjectHandle object.
 ObjectHandle (Allocator &allocator, T *ptr=nullptr)
 Constructs an ObjectHandle object.
 ObjectHandle (ObjectHandle &&other)
 Constructs an ObjectHandle object that takes ownership of the object owned by another.
ObjectHandle & operator= (ObjectHandle &&other)
 Destroys the currently owned object and takes ownership of the object owned by another ObjectHandle.
template<typename U, typename Bond::enable_if< Bond::is_same< U, T >::value||Bond::has_virtual_destructor< U >::value, int >::type = 0>
 operator ObjectHandle< U > () &&
 Transfers ownership of the object to an ObjectHandle of another type, which must be T or have a virtual destructor so that the object is destroyed correctly.

Detailed Description

template<typename T>
class Bond::Allocator::ObjectHandle< T >

An owning object handle that derives from unique_ptr that destroys an object using an ObjectDeallocator rather than std::default_delete when it goes out of scope.

Constructor & Destructor Documentation

◆ ObjectHandle() [1/3]

template<typename T>
Bond::Allocator::ObjectHandle< T >::ObjectHandle ( Allocator * allocator = nullptr,
T * ptr = nullptr )
inline

Constructs an ObjectHandle object.

Parameters
allocatorThe allocator that frees the memory, or null if the object is not to be destroyed.
ptrPointer to the owned object, whose memory must have been allocated by allocator.

◆ ObjectHandle() [2/3]

template<typename T>
Bond::Allocator::ObjectHandle< T >::ObjectHandle ( Allocator & allocator,
T * ptr = nullptr )
inline

Constructs an ObjectHandle object.

Parameters
allocatorThe allocator that frees the memory.
ptrPointer to the owned object, whose memory must have been allocated by allocator.

◆ ObjectHandle() [3/3]

template<typename T>
Bond::Allocator::ObjectHandle< T >::ObjectHandle ( ObjectHandle< T > && other)
inline

Constructs an ObjectHandle object that takes ownership of the object owned by another.

Member Function Documentation

◆ operator ObjectHandle< U >()

template<typename T>
template<typename U, typename Bond::enable_if< Bond::is_same< U, T >::value||Bond::has_virtual_destructor< U >::value, int >::type = 0>
Bond::Allocator::ObjectHandle< T >::operator ObjectHandle< U > ( ) &&
inline

Transfers ownership of the object to an ObjectHandle of another type, which must be T or have a virtual destructor so that the object is destroyed correctly.

◆ operator=()

template<typename T>
ObjectHandle & Bond::Allocator::ObjectHandle< T >::operator= ( ObjectHandle< T > && other)
inline

Destroys the currently owned object and takes ownership of the object owned by another ObjectHandle.


The documentation for this class was generated from the following file:
  • include/bond/systems/allocator.h