1 #ifndef CYCLE_PTR_ALLOCATOR_H 2 #define CYCLE_PTR_ALLOCATOR_H 8 #include <cycle_ptr/detail/base_control.h> 18 template<
typename Nested>
42 template<
typename Other>
44 noexcept(std::is_nothrow_constructible_v<Nested, const Other&>)
46 control_(other.control_)
52 template<
typename... Args,
typename = std::enable_if_t<std::is_constructible_v<Nested, Args...>>>
54 : Nested(std::forward<Args>(args)...),
55 control_(base.control_)
61 template<
typename... Args,
typename = std::enable_if_t<std::is_constructible_v<Nested, Args...>>>
63 : Nested(std::forward<Args>(args)...),
64 control_(detail::base_control::unowned_control())
76 template<
typename T,
typename... Args>
80 std::allocator_traits<Nested>::construct(*
this, ptr, std::forward<Args>(args)...);
93 template<
typename Dummy =
void>
96 static_assert(std::is_void_v<Dummy> &&
false,
97 "You must explicitly specify an allocator with owner during copy.");
111 std::allocator_traits<Nested>::is_always_equal::value
112 || noexcept(std::declval<const Nested&>() == std::declval<const Nested&>()))
114 if constexpr(!std::allocator_traits<Nested>::is_always_equal::value) {
115 if (!std::equal_to<Nested>()(*
this, other))
return false;
118 return control_ == other.control_
119 || (control_->is_unowned() && other.control_->is_unowned());
124 noexcept(noexcept(*
this == other))
126 return !(*
this == other);
auto select_on_container_copy_construction() -> cycle_allocator
Fail to create copy of this allocator.
Definition: allocator.h:94
Adaptor for collections with member types.
Definition: allocator.h:19
cycle_allocator(const cycle_base &base, Args &&... args)
Create allocator, with declared ownership.
Definition: allocator.h:53
std::false_type propagate_on_container_move_assignment
When move-assigning, allocator is not copied over.
Definition: allocator.h:28
Address range publisher.
Definition: base_control.h:215
Intrusive pointer.
Definition: intrusive_ptr.h:21
cycle_allocator([[maybe_unused]] unowned_cycle_t unowned_tag, Args &&... args)
Create allocator, with elements having no ownership.
Definition: allocator.h:62
std::false_type propagate_on_container_swap
When performing swap, allocator is not swapped.
Definition: allocator.h:30
cycle_allocator(const cycle_allocator< Other > &other) noexcept(std::is_nothrow_constructible_v< Nested, const Other & >)
Copy constructor for distinct type.
Definition: allocator.h:43
std::false_type is_always_equal
Must check for equality.
Definition: allocator.h:32
Tag indicating an edge without owner.
Definition: cycle_ptr.h:24
auto construct(T *ptr, Args &&... args) -> void
Constructor.
Definition: allocator.h:77
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.
Definition: allocator.h:109
An optional base for classes which need to supply ownership to cycle_member_ptr.
Definition: cycle_ptr.h:49
std::false_type propagate_on_container_copy_assignment
When copy-assigning, allocator is not copied over.
Definition: allocator.h:26
auto operator!=(const cycle_allocator &other) const noexcept(noexcept(*this==other)) -> bool
Inequality comparison.
Definition: allocator.h:123
Template for changing controlled type of allocator.
Definition: allocator.h:36