joint_ptr< T, RawAllocator > Class Template Reference
Allocator implementations

## Detailed Description

template<typename T, class RawAllocator>
class foonathan::memory::joint_ptr< T, RawAllocator >

A pointer to an object where all allocations are joint.

It can either own an object or not (be `nullptr`). When it owns an object, it points to a memory block. This memory block contains both the actual object (of the type `T`) and space for allocations of `T`s members.

The type `T` must be derived from joint_type and every constructor must take joint as first parameter. This prevents that you create joint objects yourself, without the additional storage. The default copy and move constructors are also deleted, you need to write them yourself.

You can only access the object through the pointer, use joint_allocator or joint_array as members of `T`, to enable the memory sharing. If you are using joint_allocator inside STL containers, make sure that you do not call their regular copy/move constructors, but instead the version where you pass an allocator.

The memory block will be managed by the given RawAllocator, it is stored in an allocator_reference and not owned by the pointer directly.

## Typedefs

using | element_type = T
using | allocator_type = typename allocator_reference< RawAllocator >::allocator_type

## Member Functions

| joint_ptr (joint_ptr &&other) noexcept
| ~joint_ptr () noexcept
joint_ptr & | operator= (joint_ptr &&other) noexcept
joint_ptr & | operator= (std::nullptr_t) noexcept
void | reset () noexcept
| operator bool () const noexcept
element_type & | operator* () const noexcept
element_type * | operator-> () const noexcept
element_type * | get () const noexcept
auto | get_allocator () const noexcept -> decltype(std::declval< allocator_reference< allocator_type > >().get_allocator())
| joint_ptr (allocator_type &alloc) noexcept
| joint_ptr (const allocator_type &alloc) noexcept
template<typename... Args>
| joint_ptr (allocator_type &alloc, joint_size additional_size, Args &&... args)
template<typename... Args>
| joint_ptr (const allocator_type &alloc, joint_size additional_size, Args &&... args)

## Constructors

## joint_ptr() [1/5]

template<typename T , class RawAllocator >

joint_ptr | ( | allocator_type & | alloc | ) |

explicit noexcept

Effects:
  Creates it with a RawAllocator, but does not own a new object.

## joint_ptr() [2/5]

template<typename T , class RawAllocator >

joint_ptr | ( | const allocator_type & | alloc | ) |

explicit noexcept

Effects:
  Creates it with a RawAllocator, but does not own a new object.

## joint_ptr() [3/5]

template<typename T , class RawAllocator >
template<typename... Args>

joint_ptr | ( | allocator_type & | alloc,
|  | joint_size | additional_size,
|  | Args &&... | args
| ) |  |

Effects:
  Reserves memory for the object and the additional size, and creates the object by forwarding the arguments to its constructor. The RawAllocator will be used for the allocation.

## joint_ptr() [4/5]

template<typename T , class RawAllocator >
template<typename... Args>

joint_ptr | ( | const allocator_type & | alloc,
|  | joint_size | additional_size,
|  | Args &&... | args
| ) |  |

Effects:
  Reserves memory for the object and the additional size, and creates the object by forwarding the arguments to its constructor. The RawAllocator will be used for the allocation.

## joint_ptr() [5/5]

template<typename T , class RawAllocator >

joint_ptr | ( | joint_ptr< T, RawAllocator > && | other | ) |

noexcept

Effects:
  Move-constructs the pointer. Ownership will be transferred from `other` to the new object.

## ~joint_ptr()

template<typename T , class RawAllocator >

~joint_ptr | ( |  | ) |

noexcept

Effects:
  Destroys the object and deallocates its storage.

## Member Functions

## operator=() [1/2]

template<typename T , class RawAllocator >

joint_ptr & operator= | ( | joint_ptr< T, RawAllocator > && | other | ) |

noexcept

Effects:
  Move-assings the pointer. The previously owned object will be destroyed, and ownership of `other` transferred.

## operator=() [2/2]

template<typename T , class RawAllocator >

joint_ptr & operator= | ( | std::nullptr_t |  | ) |

noexcept

Effects:
  Same as `reset()`.

## reset()

template<typename T , class RawAllocator >

void reset | ( |  | ) |

noexcept

Effects:
  Destroys the object it refers to, if there is any.

## operator bool()

template<typename T , class RawAllocator >

operator bool | ( |  | ) | const

explicit noexcept

Returns:
  `true` if the pointer does own an object, `false` otherwise.

## operator*()

template<typename T , class RawAllocator >

element_type & operator* | ( |  | ) | const

noexcept

Returns:
  A reference to the object it owns.

Requires:
  The pointer must own an object, i.e. `operator bool()` must return `true`.

## operator->()

template<typename T , class RawAllocator >

element_type * operator-> | ( |  | ) | const

noexcept

Returns:
  A pointer to the object it owns.

Requires:
  The pointer must own an object, i.e. `operator bool()` must return `true`.

## get()

template<typename T , class RawAllocator >

element_type * get | ( |  | ) | const

noexcept

Returns:
  A pointer to the object it owns or `nullptr`, if it does not own any object.

## get_allocator()

template<typename T , class RawAllocator >

auto get_allocator | ( |  | ) | const -> decltype(std::declval<allocator_reference<allocator_type>>().get_allocator())

noexcept

Returns:
  A reference to the allocator it will use for the deallocation.