cycle_ptr
Classes | Public Types | Public Member Functions | Friends | List of all members
cycle_ptr::cycle_allocator< Nested > Class Template Reference

Adaptor for collections with member types. More...

#include <allocator.h>

Inheritance diagram for cycle_ptr::cycle_allocator< Nested >:
Inheritance graph
[legend]
Collaboration diagram for cycle_ptr::cycle_allocator< Nested >:
Collaboration graph
[legend]

Classes

struct  rebind
 Template for changing controlled type of allocator. More...
 

Public Types

using propagate_on_container_copy_assignment = std::false_type
 When copy-assigning, allocator is not copied over.
 
using propagate_on_container_move_assignment = std::false_type
 When move-assigning, allocator is not copied over.
 
using propagate_on_container_swap = std::false_type
 When performing swap, allocator is not swapped.
 
using is_always_equal = std::false_type
 Must check for equality.
 

Public Member Functions

template<typename Other >
 cycle_allocator (const cycle_allocator< Other > &other) noexcept(std::is_nothrow_constructible_v< Nested, const Other & >)
 Copy constructor for distinct type.
 
template<typename... Args, typename = std::enable_if_t<std::is_constructible_v<Nested, Args...>>>
 cycle_allocator (const cycle_base &base, Args &&... args)
 Create allocator, with declared ownership. More...
 
template<typename... Args, typename = std::enable_if_t<std::is_constructible_v<Nested, Args...>>>
 cycle_allocator ([[maybe_unused]] unowned_cycle_t unowned_tag, Args &&... args)
 Create allocator, with elements having no ownership. More...
 
template<typename T , typename... Args>
auto construct (T *ptr, Args &&... args) -> void
 Constructor. More...
 
template<typename Dummy = void>
auto select_on_container_copy_construction () -> cycle_allocator
 Fail to create copy of this allocator. More...
 
auto operator== (const cycle_allocator &other) const noexcept(std::allocator_traits< Nested >::is_always_equal::value||noexcept(std::declval< const Nested & >()==std::declval< const Nested & >())) -> bool
 Compare allocators for equality. More...
 
auto operator!= (const cycle_allocator &other) const noexcept(noexcept(*this==other)) -> bool
 Inequality comparison.
 

Friends

template<typename >
class cycle_allocator
 

Detailed Description

template<typename Nested>
class cycle_ptr::cycle_allocator< Nested >

Adaptor for collections with member types.

Member types are owned by the owner supplied at allocator construction.

Template Parameters
NestedUnderlying allocator.

Constructor & Destructor Documentation

◆ cycle_allocator() [1/2]

template<typename Nested>
template<typename... Args, typename = std::enable_if_t<std::is_constructible_v<Nested, Args...>>>
cycle_ptr::cycle_allocator< Nested >::cycle_allocator ( const cycle_base base,
Args &&...  args 
)
inlineexplicit

Create allocator, with declared ownership.

Parameters
baseThe owner of elements created using this allocator.
argsArguments to pass to underlying allocator constructor.

◆ cycle_allocator() [2/2]

template<typename Nested>
template<typename... Args, typename = std::enable_if_t<std::is_constructible_v<Nested, Args...>>>
cycle_ptr::cycle_allocator< Nested >::cycle_allocator ( [[maybe_unused] ] unowned_cycle_t  unowned_tag,
Args &&...  args 
)
inlineexplicit

Create allocator, with elements having no ownership.

Parameters
unowned_tagTag indicating that elements created by this allocator do not have an owning object.
argsArguments to pass to underlying allocator constructor.

Member Function Documentation

◆ construct()

template<typename Nested>
template<typename T , typename... Args>
auto cycle_ptr::cycle_allocator< Nested >::construct ( T *  ptr,
Args &&...  args 
) -> void
inline

Constructor.

Publishes the owner control block prior to construction, to allow for members to pick it up automatically. (After construction, the control block is unpublished.)

Forwards to construct as implemented by Nested.

◆ operator==()

template<typename Nested>
auto cycle_ptr::cycle_allocator< Nested >::operator== ( const cycle_allocator< Nested > &  other) const -> bool
inlinenoexcept

Compare allocators for equality.

Two allocators are equal if they use the same owner.

(Distinct owners are treated as equal if they represent the unowned control block.)

◆ select_on_container_copy_construction()

template<typename Nested>
template<typename Dummy = void>
auto cycle_ptr::cycle_allocator< Nested >::select_on_container_copy_construction ( ) -> cycle_allocator
inline

Fail to create copy of this allocator.

Fails a static assert with a message asking you to please explicitly specify what ownership relation to use for copied container.

Note
Ideally, this would also be possible for move construction of a container, but there's no support for that in the C++ Standard Library.

The documentation for this class was generated from the following file: