[hive]

# 23 Containers library [[containers]](./#containers)

## 23.3 Sequence containers [[sequences]](sequences#hive)

### 23.3.9 Class template hive [hive]

#### [23.3.9.1](#overview) Overview [[hive.overview]](hive.overview)

[1](#overview-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L7915)

A hive is a type of sequence container
that provides constant-time insertion and erasure operations[.](#overview-1.sentence-1)

Storage is automatically managed in multiple memory blocks,
referred to as [*element blocks*](#def:element_block "23.3.9.1 Overview [hive.overview]")[.](#overview-1.sentence-2)

Insertion position is determined by the container, and insertion
may re-use the memory locations of erased elements[.](#overview-1.sentence-3)

[2](#overview-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L7923)

Element blocks which contain elements are referred to
as [*active blocks*](#def:block,active "23.3.9.1 Overview [hive.overview]"),
those which do not are referred to as [*reserved blocks*](#def:block,reserved "23.3.9.1 Overview [hive.overview]")[.](#overview-2.sentence-1)

Active blocks which become empty of elements are
either deallocated or become reserved blocks[.](#overview-2.sentence-2)

Reserved blocks become active blocks when they are used to store elements[.](#overview-2.sentence-3)

A user can create additional reserved blocks by calling reserve[.](#overview-2.sentence-4)

[3](#overview-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L7932)

Erasures use unspecified techniques of constant time complexity
to identify the memory locations of erased elements,
which are subsequently skipped during iteration,
as opposed to relocating subsequent elements during erasure[.](#overview-3.sentence-1)

[4](#overview-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L7938)

Active block capacities have
an implementation-defined growth factor
(which need not be integral),
for example a new active block's capacity could be equal to
the summed capacities of the pre-existing active blocks[.](#overview-4.sentence-1)

[5](#overview-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L7945)

Limits can be placed on
both the minimum and maximum element capacities of element blocks,
both by users and implementations[.](#overview-5.sentence-1)

- [(5.1)](#overview-5.1)

  The minimum limit shall be no larger than the maximum limit[.](#overview-5.1.sentence-1)

- [(5.2)](#overview-5.2)

  When limits are not specified by a user during construction,
the implementation's default limits are used[.](#overview-5.2.sentence-1)

- [(5.3)](#overview-5.3)

  The default limits of an implementation are not guaranteed to be the same as
the minimum and maximum possible capacities
for an implementation's element blocks[.](#overview-5.3.sentence-1)
  [*Note [1](#overview-note-1)*:
  To allow latitude for
both implementation-specific and user-directed optimization[.](#overview-5.3.sentence-2)
 â *end note*]
   The latter are defined as hard limits[.](#overview-5.3.sentence-3)
  The maximum hard limit shall be no larger thanstd​::​allocator_traits<Allocator>​::​max_size()[.](#overview-5.3.sentence-4)

- [(5.4)](#overview-5.4)

  If user-specified limits are not within hard limits, or
if the specified minimum limit is greater than the specified maximum limit,
the behavior is undefined[.](#overview-5.4.sentence-1)

- [(5.5)](#overview-5.5)

  An element block is said to be [*within the bounds*](#def:element_block,bounds "23.3.9.1 Overview [hive.overview]") of a pair of minimum/maximum limits
when its capacity is greater-or-equal-to the minimum limit and
less-than-or-equal-to the maximum limit[.](#overview-5.5.sentence-1)

[6](#overview-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L7977)

A hive conforms to
the requirements for containers ([[container.reqmts]](container.reqmts "23.2.2.2 Container requirements")),
with the exception of operators == and !=[.](#overview-6.sentence-1)

A hive also meets the requirements
of a reversible container ([[container.rev.reqmts]](container.rev.reqmts "23.2.2.3 Reversible container requirements")),
of an allocator-aware container ([[container.alloc.reqmts]](container.alloc.reqmts "23.2.2.5 Allocator-aware containers")), and
some of the requirements of a sequence container ([[sequence.reqmts]](sequence.reqmts "23.2.4 Sequence containers"))[.](#overview-6.sentence-2)

Descriptions are provided here only for operations on hive that are not described in that table or for operations
where there is additional semantic information[.](#overview-6.sentence-3)

[7](#overview-7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L7989)

The iterators of hive meet
the *Cpp17BidirectionalIterator* requirements
but also model [three_way_comparable](cmp.concept#concept:three_way_comparable "17.12.4 Concept three_­way_­comparable [cmp.concept]")<strong_ordering>[.](#overview-7.sentence-1)

namespace std {template<class T, class Allocator = allocator<T>>class [hive](#lib:hive "23.3.9.1 Overview [hive.overview]") {public:// typesusing value_type = T; using allocator_type = Allocator; using pointer = typename allocator_traits<Allocator>::pointer; using const_pointer = typename allocator_traits<Allocator>::const_pointer; using reference = value_type&; using const_reference = const value_type&; using size_type = *implementation-defined*; // see [[container.requirements]](container.requirements "23.2 Requirements")using difference_type = *implementation-defined*; // see [[container.requirements]](container.requirements "23.2 Requirements")using iterator = *implementation-defined*; // see [[container.requirements]](container.requirements "23.2 Requirements")using const_iterator = *implementation-defined*; // see [[container.requirements]](container.requirements "23.2 Requirements")using reverse_iterator = std::reverse_iterator<iterator>; // see [[container.requirements]](container.requirements "23.2 Requirements")using const_reverse_iterator = std::reverse_iterator<const_iterator>; // see [[container.requirements]](container.requirements "23.2 Requirements")// [[hive.cons]](#cons "23.3.9.2 Constructors, copy, and assignment"), construct/copy/destroyconstexpr hive() noexcept(noexcept(Allocator())) : hive(Allocator()) {}constexpr explicit hive(const Allocator&) noexcept; constexpr explicit hive(hive_limits block_limits) : hive(block_limits, Allocator()) {}constexpr hive(hive_limits block_limits, const Allocator&); explicit hive(size_type n, const Allocator& = Allocator());
 hive(size_type n, hive_limits block_limits, const Allocator& = Allocator());
 hive(size_type n, const T& value, const Allocator& = Allocator());
 hive(size_type n, const T& value, hive_limits block_limits, const Allocator& = Allocator()); template<class InputIterator> hive(InputIterator first, InputIterator last, const Allocator& = Allocator()); template<class InputIterator> hive(InputIterator first, InputIterator last, hive_limits block_limits, const Allocator& = Allocator()); template<[*container-compatible-range*](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]")<T> R> hive(from_range_t, R&& rg, const Allocator& = Allocator()); template<[*container-compatible-range*](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]")<T> R> hive(from_range_t, R&& rg, hive_limits block_limits, const Allocator& = Allocator());
 hive(const hive& x);
 hive(hive&&) noexcept;
 hive(const hive& x, const type_identity_t<Allocator>& alloc);
 hive(hive&&, const type_identity_t<Allocator>& alloc);
 hive(initializer_list<T> il, const Allocator& = Allocator());
 hive(initializer_list<T> il, hive_limits block_limits, const Allocator& = Allocator()); ~hive();

 hive& operator=(const hive& x);
 hive& operator=(hive&& x) noexcept(*see below*);
 hive& operator=(initializer_list<T>); template<class InputIterator>void assign(InputIterator first, InputIterator last); template<[*container-compatible-range*](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]")<T> R>void assign_range(R&& rg); void assign(size_type n, const T& t); void assign(initializer_list<T>);
 allocator_type get_allocator() const noexcept; // iterators iterator begin() noexcept;
 const_iterator begin() const noexcept;
 iterator end() noexcept;
 const_iterator end() const noexcept;
 reverse_iterator rbegin() noexcept;
 const_reverse_iterator rbegin() const noexcept;
 reverse_iterator rend() noexcept;
 const_reverse_iterator rend() const noexcept;
 const_iterator cbegin() const noexcept;
 const_iterator cend() const noexcept;
 const_reverse_iterator crbegin() const noexcept;
 const_reverse_iterator crend() const noexcept; // [[hive.capacity]](#capacity "23.3.9.3 Capacity"), capacitybool empty() const noexcept;
 size_type size() const noexcept;
 size_type max_size() const noexcept;
 size_type capacity() const noexcept; void reserve(size_type n); void shrink_to_fit(); void trim_capacity() noexcept; void trim_capacity(size_type n) noexcept; constexpr hive_limits block_capacity_limits() const noexcept; static constexpr hive_limits block_capacity_default_limits() noexcept; static constexpr hive_limits block_capacity_hard_limits() noexcept; void reshape(hive_limits block_limits); // [[hive.modifiers]](#modifiers "23.3.9.4 Modifiers"), modifierstemplate<class... Args> iterator emplace(Args&&... args); template<class... Args> iterator emplace_hint(const_iterator hint, Args&&... args);
 iterator insert(const T& x);
 iterator insert(T&& x);
 iterator insert(const_iterator hint, const T& x);
 iterator insert(const_iterator hint, T&& x); void insert(initializer_list<T> il); template<[*container-compatible-range*](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]")<T> R>void insert_range(R&& rg); template<class InputIterator>void insert(InputIterator first, InputIterator last); void insert(size_type n, const T& x);

 iterator erase(const_iterator position);
 iterator erase(const_iterator first, const_iterator last); void swap(hive&) noexcept(*see below*); void clear() noexcept; // [[hive.operations]](#operations "23.3.9.5 Operations"), hive operationsvoid splice(hive& x); void splice(hive&& x); template<class BinaryPredicate = equal_to<T>> size_type unique(BinaryPredicate binary_pred = BinaryPredicate()); template<class Compare = less<T>>void sort(Compare comp = Compare());

 iterator get_iterator(const_pointer p) noexcept;
 const_iterator get_iterator(const_pointer p) const noexcept; private: hive_limits *current-limits* = *implementation-defined*; // *exposition only*}; template<class InputIterator, class Allocator = allocator<*iter-value-type*<InputIterator>>> hive(InputIterator, InputIterator, Allocator = Allocator())-> hive<*iter-value-type*<InputIterator>, Allocator>; template<class InputIterator, class Allocator = allocator<*iter-value-type*<InputIterator>>> hive(InputIterator, InputIterator, hive_limits, Allocator = Allocator())-> hive<*iter-value-type*<InputIterator>, Allocator>; template<ranges::[input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]") R, class Allocator = allocator<ranges::range_value_t<R>>> hive(from_range_t, R&&, Allocator = Allocator())-> hive<ranges::range_value_t<R>, Allocator>; template<ranges::[input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]") R, class Allocator = allocator<ranges::range_value_t<R>>> hive(from_range_t, R&&, hive_limits, Allocator = Allocator())-> hive<ranges::range_value_t<R>, Allocator>;}

#### [23.3.9.2](#cons) Constructors, copy, and assignment [[hive.cons]](hive.cons)

[ð](#lib:hive,constructor)

`constexpr explicit hive(const Allocator&) noexcept;
`

[1](#cons-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8139)

*Effects*: Constructs an empty hive, using the specified allocator[.](#cons-1.sentence-1)

[2](#cons-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8143)

*Complexity*: Constant[.](#cons-2.sentence-1)

[ð](#lib:hive,constructor_)

`constexpr hive(hive_limits block_limits, const Allocator&);
`

[3](#cons-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8154)

*Effects*: Constructs an empty hive, using the specified allocator[.](#cons-3.sentence-1)

Initializes *current-limits* with block_limits[.](#cons-3.sentence-2)

[4](#cons-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8159)

*Complexity*: Constant[.](#cons-4.sentence-1)

[ð](#lib:hive,constructor__)

`explicit hive(size_type n, const Allocator& = Allocator());
hive(size_type n, hive_limits block_limits, const Allocator& = Allocator());
`

[5](#cons-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8171)

*Preconditions*: T is *Cpp17DefaultInsertable* into hive[.](#cons-5.sentence-1)

[6](#cons-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8175)

*Effects*: Constructs a hive with n default-inserted elements,
using the specified allocator[.](#cons-6.sentence-1)

If the second overload is called,
also initializes *current-limits* with block_limits[.](#cons-6.sentence-2)

[7](#cons-7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8182)

*Complexity*: Linear in n[.](#cons-7.sentence-1)

[ð](#lib:hive,constructor___)

`hive(size_type n, const T& value, const Allocator& = Allocator());
hive(size_type n, const T& value, hive_limits block_limits, const Allocator& = Allocator());
`

[8](#cons-8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8194)

*Preconditions*: T is *Cpp17CopyInsertable* into hive[.](#cons-8.sentence-1)

[9](#cons-9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8198)

*Effects*: Constructs a hive with n copies of value,
using the specified allocator[.](#cons-9.sentence-1)

If the second overload is called,
also initializes *current-limits* with block_limits[.](#cons-9.sentence-2)

[10](#cons-10)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8205)

*Complexity*: Linear in n[.](#cons-10.sentence-1)

[ð](#lib:hive,constructor____)

`template<class InputIterator>
  hive(InputIterator first, InputIterator last, const Allocator& = Allocator());
template<class InputIterator>
  hive(InputIterator first, InputIterator last, hive_limits block_limits,
       const Allocator& = Allocator());
`

[11](#cons-11)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8220)

*Effects*: Constructs a hive equal to the range [first, last),
using the specified allocator[.](#cons-11.sentence-1)

If the second overload is called,
also initializes *current-limits* with block_limits[.](#cons-11.sentence-2)

[12](#cons-12)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8227)

*Complexity*: Linear in distance(first, last)[.](#cons-12.sentence-1)

[ð](#lib:hive,constructor_____)

`template<[container-compatible-range](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]")<T> R>
  hive(from_range_t, R&& rg, const Allocator& = Allocator());
template<[container-compatible-range](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]")<T> R>
  hive(from_range_t, R&& rg, hive_limits block_limits, const Allocator& = Allocator());
`

[13](#cons-13)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8241)

*Effects*: Constructs a hive object with the elements of the range rg,
using the specified allocator[.](#cons-13.sentence-1)

If the second overload is called,
also initializes *current-limits* with block_limits[.](#cons-13.sentence-2)

[14](#cons-14)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8248)

*Complexity*: Linear in ranges​::​distance(rg)[.](#cons-14.sentence-1)

[ð](#lib:hive,constructor______)

`hive(const hive& x);
hive(const hive& x, const type_identity_t<Allocator>& alloc);
`

[15](#cons-15)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8260)

*Preconditions*: T is *Cpp17CopyInsertable* into hive[.](#cons-15.sentence-1)

[16](#cons-16)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8264)

*Effects*: Constructs a hive object with the elements of x[.](#cons-16.sentence-1)

If the second overload is called, uses alloc[.](#cons-16.sentence-2)

Initializes *current-limits* with x.*current-limits*[.](#cons-16.sentence-3)

[17](#cons-17)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8270)

*Complexity*: Linear in x.size()[.](#cons-17.sentence-1)

[ð](#lib:hive,constructor_______)

`hive(hive&& x) noexcept;
hive(hive&& x, const type_identity_t<Allocator>& alloc);
`

[18](#cons-18)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8282)

*Preconditions*: For the second overload,
when allocator_traits<alloc>​::​is_always_equal​::​value is false,T meets the *Cpp17MoveInsertable* requirements[.](#cons-18.sentence-1)

[19](#cons-19)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8288)

*Effects*: When the first overload is called, or
the second overload is called andalloc == x.get_allocator() is true,*current-limits* is set to x.*current-limits* and
each element block is moved from x into *this[.](#cons-19.sentence-1)

Pointers and references to the elements of x now refer to
those same elements but as members of *this[.](#cons-19.sentence-2)

Iterators referring to the elements of x will continue to refer to their elements,
but they now behave as iterators into *this[.](#cons-19.sentence-3)

If the second overload is called andalloc == x.get_allocator() is false,
each element in x is moved into *this[.](#cons-19.sentence-4)

References, pointers and iterators referring to the elements of x, as well as the past-the-end iterator of x, are invalidated[.](#cons-19.sentence-5)

[20](#cons-20)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8306)

*Postconditions*: x.empty() is true[.](#cons-20.sentence-1)

[21](#cons-21)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8310)

*Complexity*: If the second overload is called andalloc == x.get_allocator() is false, linear in x.size()[.](#cons-21.sentence-1)

Otherwise constant[.](#cons-21.sentence-2)

[ð](#lib:hive,constructor________)

`hive(initializer_list<T> il, const Allocator& = Allocator());
hive(initializer_list<T> il, hive_limits block_limits, const Allocator& = Allocator());
`

[22](#cons-22)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8324)

*Preconditions*: T is *Cpp17CopyInsertable* into hive[.](#cons-22.sentence-1)

[23](#cons-23)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8328)

*Effects*: Constructs a hive object with the elements of il,
using the specified allocator[.](#cons-23.sentence-1)

If the second overload is called,
also initializes *current-limits* with block_limits[.](#cons-23.sentence-2)

[24](#cons-24)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8335)

*Complexity*: Linear in il.size()[.](#cons-24.sentence-1)

[ð](#lib:operator=,hive)

`hive& operator=(const hive& x);
`

[25](#cons-25)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8346)

*Preconditions*: T is *Cpp17CopyInsertable* into hive and*Cpp17CopyAssignable*[.](#cons-25.sentence-1)

[26](#cons-26)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8351)

*Effects*: All elements in *this are either copy-assigned to, or destroyed[.](#cons-26.sentence-1)

All elements in x are copied into *this[.](#cons-26.sentence-2)

[*Note [1](#cons-note-1)*:

*current-limits* is unchanged[.](#cons-26.sentence-3)

â *end note*]

[27](#cons-27)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8359)

*Complexity*: Linear in size() + x.size()[.](#cons-27.sentence-1)

[ð](#lib:operator=,hive_)

`hive& operator=(hive&& x)
  noexcept(allocator_traits<Allocator>::propagate_on_container_move_assignment::value ||
           allocator_traits<Allocator>::is_always_equal::value);
`

[28](#cons-28)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8372)

*Preconditions*: When(allocator_traits<Allocator>::propagate_on_container_move_assignment::value || allocator_traits<Allocator>::is_always_equal::value) is false,T is *Cpp17MoveInsertable* into hive and*Cpp17MoveAssignable*[.](#cons-28.sentence-1)

[29](#cons-29)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8383)

*Effects*: Each element in *this is either move-assigned to, or destroyed[.](#cons-29.sentence-1)

When(allocator_traits<Allocator>::propagate_on_container_move_assignment::value || get_allocator() == x.get_allocator()) is true,*current-limits* is set to x.*current-limits* and
each element block is moved from x into *this[.](#cons-29.sentence-2)

Pointers and references to the elements of x now refer to those same elements but as members of *this[.](#cons-29.sentence-3)

Iterators referring to the elements of x will continue to refer to their elements,
but they now behave as iterators into *this, not into x[.](#cons-29.sentence-4)

When(allocator_traits<Allocator>::propagate_on_container_move_assignment::value || get_allocator() == x.get_allocator()) is false,
each element in x is moved into *this[.](#cons-29.sentence-5)

References, pointers and iterators referring to the elements of x,
as well as the past-the-end iterator of x, are invalidated[.](#cons-29.sentence-6)

[30](#cons-30)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8410)

*Postconditions*: x.empty() is true[.](#cons-30.sentence-1)

[31](#cons-31)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8414)

*Complexity*: Linear in size()[.](#cons-31.sentence-1)

If(allocator_traits<Allocator>::propagate_on_container_move_assignment::value || get_allocator() == x.get_allocator()) is false, also linear in x.size()[.](#cons-31.sentence-2)

#### [23.3.9.3](#capacity) Capacity [[hive.capacity]](hive.capacity)

[ð](#lib:capacity,hive)

`size_type capacity() const noexcept;
`

[1](#capacity-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8433)

*Returns*: The total number of elements that *this can hold
without requiring allocation of more element blocks[.](#capacity-1.sentence-1)

[2](#capacity-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8438)

*Complexity*: Constant[.](#capacity-2.sentence-1)

[ð](#lib:reserve,hive)

`void reserve(size_type n);
`

[3](#capacity-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8449)

*Effects*: If n <= capacity() is true, there are no effects[.](#capacity-3.sentence-1)

Otherwise increases capacity() by allocating reserved blocks[.](#capacity-3.sentence-2)

[4](#capacity-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8454)

*Postconditions*: capacity() >= n is true[.](#capacity-4.sentence-1)

[5](#capacity-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8458)

*Throws*: length_error if n > max_size(),
as well as any exceptions thrown by the allocator[.](#capacity-5.sentence-1)

[6](#capacity-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8463)

*Complexity*: It does not change the size of the sequence and
takes at most linear time in the number of reserved blocks allocated[.](#capacity-6.sentence-1)

[7](#capacity-7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8468)

*Remarks*: All references, pointers, and iterators referring to elements in *this,
as well as the past-the-end iterator, remain valid[.](#capacity-7.sentence-1)

[ð](#lib:shrink_to_fit,hive)

`void shrink_to_fit();
`

[8](#capacity-8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8480)

*Preconditions*: T is *Cpp17MoveInsertable* into hive[.](#capacity-8.sentence-1)

[9](#capacity-9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8484)

*Effects*: shrink_to_fit is a non-binding request
to reduce capacity() to be closer to size()[.](#capacity-9.sentence-1)

[*Note [1](#capacity-note-1)*:

The request is non-binding
to allow latitude for implementation-specific optimizations[.](#capacity-9.sentence-2)

â *end note*]

It does not increase capacity(), but may reduce capacity()[.](#capacity-9.sentence-3)

It may reallocate elements[.](#capacity-9.sentence-4)

If capacity() is already equal to size(), there are no effects[.](#capacity-9.sentence-5)

If an exception is thrown during allocation of a new element block,capacity() may be reduced and reallocation may occur[.](#capacity-9.sentence-6)

Otherwise if an exception is thrown, the effects are unspecified[.](#capacity-9.sentence-7)

[10](#capacity-10)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8499)

*Complexity*: If reallocation happens, linear in the size of the sequence[.](#capacity-10.sentence-1)

[11](#capacity-11)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8503)

*Remarks*: If reallocation happens,
the order of the elements in *this may change and
all references, pointers, and iterators
referring to the elements in *this,
as well as the past-the-end iterator, are invalidated[.](#capacity-11.sentence-1)

[ð](#lib:trim_capacity,hive)

`void trim_capacity() noexcept;
void trim_capacity(size_type n) noexcept;
`

[12](#capacity-12)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8519)

*Effects*: For the first overload, all reserved blocks are deallocated, andcapacity() is reduced accordingly[.](#capacity-12.sentence-1)

For the second overload, capacity() is reduced to no less than n[.](#capacity-12.sentence-2)

[13](#capacity-13)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8525)

*Complexity*: Linear in the number of reserved blocks deallocated[.](#capacity-13.sentence-1)

[14](#capacity-14)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8529)

*Remarks*: All references, pointers, and iterators referring to elements in *this,
as well as the past-the-end iterator, remain valid[.](#capacity-14.sentence-1)

[ð](#lib:block_capacity_limits,hive)

`constexpr hive_limits block_capacity_limits() const noexcept;
`

[15](#capacity-15)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8541)

*Returns*: *current-limits*[.](#capacity-15.sentence-1)

[16](#capacity-16)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8545)

*Complexity*: Constant[.](#capacity-16.sentence-1)

[ð](#lib:block_capacity_default_limits,hive)

`static constexpr hive_limits block_capacity_default_limits() noexcept;
`

[17](#capacity-17)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8556)

*Returns*: A hive_limits struct
with the min and max members set to
the implementation's default limits[.](#capacity-17.sentence-1)

[18](#capacity-18)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8562)

*Complexity*: Constant[.](#capacity-18.sentence-1)

[ð](#lib:block_capacity_hard_limits,hive)

`static constexpr hive_limits block_capacity_hard_limits() noexcept;
`

[19](#capacity-19)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8573)

*Returns*: A hive_limits struct
with the min and max members set to
the implementation's hard limits[.](#capacity-19.sentence-1)

[20](#capacity-20)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8579)

*Complexity*: Constant[.](#capacity-20.sentence-1)

[ð](#lib:reshape,hive)

`void reshape(hive_limits block_limits);
`

[21](#capacity-21)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8590)

*Preconditions*: T is *Cpp17MoveInsertable* into hive[.](#capacity-21.sentence-1)

[22](#capacity-22)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8594)

*Effects*: For any active blocks not within the bounds of block_limits,
the elements within those active blocks are reallocated
to new or existing element blocks which are within the bounds[.](#capacity-22.sentence-1)

Any element blocks not within the bounds of block_limits are deallocated[.](#capacity-22.sentence-2)

If an exception is thrown during allocation of a new element block,capacity() may be reduced,
reallocation may occur, and*current-limits* may be assigned
a value other than block_limits[.](#capacity-22.sentence-3)

Otherwise block_limits is assigned to *current-limits*[.](#capacity-22.sentence-4)

If any other exception is thrown the effects are unspecified[.](#capacity-22.sentence-5)

[23](#capacity-23)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8609)

*Postconditions*: size() is unchanged[.](#capacity-23.sentence-1)

[24](#capacity-24)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8613)

*Complexity*: Linear in the number of element blocks in *this[.](#capacity-24.sentence-1)

If reallocation happens, also linear in the number of elements reallocated[.](#capacity-24.sentence-2)

[25](#capacity-25)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8618)

*Remarks*: This operation may change capacity()[.](#capacity-25.sentence-1)

If reallocation happens, the order of the elements in *this may change[.](#capacity-25.sentence-2)

Reallocation invalidates all references, pointers, and iterators
referring to the elements in *this,
as well as the past-the-end iterator[.](#capacity-25.sentence-3)

[*Note [2](#capacity-note-2)*:

If no reallocation happens, they remain valid[.](#capacity-25.sentence-4)

â *end note*]

#### [23.3.9.4](#modifiers) Modifiers [[hive.modifiers]](hive.modifiers)

[ð](#lib:emplace,hive)

`template<class... Args> iterator emplace(Args&&... args);
template<class... Args> iterator emplace_hint(const_iterator hint, Args&&... args);
`

[1](#modifiers-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8639)

*Preconditions*: T is *Cpp17EmplaceConstructible* into hive from args[.](#modifiers-1.sentence-1)

[2](#modifiers-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8643)

*Effects*: Inserts an object of type T constructed with std​::​forward<Args>(args)...[.](#modifiers-2.sentence-1)

The hint parameter is ignored[.](#modifiers-2.sentence-2)

If an exception is thrown, there are no effects[.](#modifiers-2.sentence-3)

[*Note [1](#modifiers-note-1)*:

args can directly or indirectly refer to a value in *this[.](#modifiers-2.sentence-4)

â *end note*]

[3](#modifiers-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8653)

*Returns*: An iterator that points to the new element[.](#modifiers-3.sentence-1)

[4](#modifiers-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8657)

*Complexity*: Constant[.](#modifiers-4.sentence-1)

Exactly one object of type T is constructed[.](#modifiers-4.sentence-2)

[5](#modifiers-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8661)

*Remarks*: Invalidates the past-the-end iterator[.](#modifiers-5.sentence-1)

[ð](#lib:insert,hive)

`iterator insert(const T& x);
iterator insert(const_iterator hint, const T& x);
iterator insert(T&& x);
iterator insert(const_iterator hint, T&& x);
`

[6](#modifiers-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8675)

*Effects*: Equivalent to: return emplace(std​::​forward<decltype(x)>(x));

[*Note [2](#modifiers-note-2)*:

The hint parameter is ignored[.](#modifiers-6.sentence-1)

â *end note*]

[ð](#lib:insert,hive_)

`void insert(initializer_list<T> rg);
template<[container-compatible-range](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]")<T> R>
  void insert_range(R&& rg);
`

[7](#modifiers-7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8691)

*Preconditions*: T is *Cpp17EmplaceInsertable* into hive from *ranges​::​begin(rg)[.](#modifiers-7.sentence-1)

rg and *this do not overlap[.](#modifiers-7.sentence-2)

[8](#modifiers-8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8697)

*Effects*: Inserts copies of elements in rg[.](#modifiers-8.sentence-1)

Each iterator in the range rg is dereferenced exactly once[.](#modifiers-8.sentence-2)

[9](#modifiers-9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8702)

*Complexity*: Linear in the number of elements inserted[.](#modifiers-9.sentence-1)

Exactly one object of type T is constructed for each element inserted[.](#modifiers-9.sentence-2)

[10](#modifiers-10)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8707)

*Remarks*: If an element is inserted, invalidates the past-the-end iterator[.](#modifiers-10.sentence-1)

[ð](#lib:insert,hive__)

`void insert(size_type n, const T& x);
`

[11](#modifiers-11)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8718)

*Preconditions*: T is *Cpp17CopyInsertable* into hive[.](#modifiers-11.sentence-1)

[12](#modifiers-12)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8722)

*Effects*: Inserts n copies of x[.](#modifiers-12.sentence-1)

[13](#modifiers-13)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8726)

*Complexity*: Linear in n[.](#modifiers-13.sentence-1)

Exactly one object of type T is constructed for each element inserted[.](#modifiers-13.sentence-2)

[14](#modifiers-14)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8731)

*Remarks*: If an element is inserted, invalidates the past-the-end iterator[.](#modifiers-14.sentence-1)

[ð](#lib:insert,hive___)

`template<class InputIterator>
  void insert(InputIterator first, InputIterator last);
`

[15](#modifiers-15)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8743)

*Effects*: Equivalent to insert_range(ranges​::​subrange(first, last))[.](#modifiers-15.sentence-1)

[ð](#lib:erase,hive)

`iterator erase(const_iterator position);
iterator erase(const_iterator first, const_iterator last);
`

[16](#modifiers-16)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8755)

*Complexity*: Linear in the number of elements erased[.](#modifiers-16.sentence-1)

Additionally, if any active blocks become empty of elements
as a result of the function call,
at worst linear in the number of element blocks[.](#modifiers-16.sentence-2)

[17](#modifiers-17)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8762)

*Remarks*: Invalidates references, pointers and iterators
referring to the erased elements[.](#modifiers-17.sentence-1)

An erase operation that erases the last element in *this also invalidates the past-the-end iterator[.](#modifiers-17.sentence-2)

[ð](#lib:swap,hive)

`void swap(hive& x)
  noexcept(allocator_traits<Allocator>::propagate_on_container_swap::value ||
           allocator_traits<Allocator>::is_always_equal::value);
`

[18](#modifiers-18)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8778)

*Effects*: Exchanges the contents, capacity(), and *current-limits* of *this with that of x[.](#modifiers-18.sentence-1)

[19](#modifiers-19)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8783)

*Complexity*: Constant[.](#modifiers-19.sentence-1)

#### [23.3.9.5](#operations) Operations [[hive.operations]](hive.operations)

[1](#operations-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8790)

In this subclause,
arguments for a template parameter
named Predicate or BinaryPredicate shall meet the corresponding requirements in [[algorithms.requirements]](algorithms.requirements "26.2 Algorithms requirements")[.](#operations-1.sentence-1)

The semantics of i + n and i - n,
where i is an iterator into the hive and n is an integer,
are the same as those of next(i, n) and prev(i, n), respectively[.](#operations-1.sentence-2)

For sort, the definitions and requirements in [[alg.sorting]](alg.sorting "26.8 Sorting and related operations") apply[.](#operations-1.sentence-3)

[ð](#lib:splice,hive)

`void splice(hive& x);
void splice(hive&& x);
`

[2](#operations-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8807)

*Preconditions*: get_allocator() == x.get_allocator() is true[.](#operations-2.sentence-1)

[3](#operations-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8811)

*Effects*: If addressof(x) == this is true,
the behavior is erroneous and there are no effects[.](#operations-3.sentence-1)

Otherwise, inserts the contents of x into *this andx becomes empty[.](#operations-3.sentence-2)

Pointers and references to the moved elements of x now refer to those same elements but as members of *this[.](#operations-3.sentence-3)

Iterators referring to the moved elements continue to refer to their elements,
but they now behave as iterators into *this, not into x[.](#operations-3.sentence-4)

[4](#operations-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8822)

*Throws*: length_error if any of x's active blocks
are not within the bounds of *current-limits*[.](#operations-4.sentence-1)

[5](#operations-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8827)

*Complexity*: Linear in the sum of
all element blocks in x plus all element blocks in *this[.](#operations-5.sentence-1)

[6](#operations-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8832)

*Remarks*: Reserved blocks in x are not transferred into *this[.](#operations-6.sentence-1)

If addressof(x) == this is false,
invalidates the past-the-end iterator for both x and *this[.](#operations-6.sentence-2)

[ð](#lib:unique,hive)

`template<class BinaryPredicate = equal_to<T>>
  size_type unique(BinaryPredicate binary_pred = BinaryPredicate());
`

[7](#operations-7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8846)

*Preconditions*: binary_pred is an equivalence relation[.](#operations-7.sentence-1)

[8](#operations-8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8850)

*Effects*: Erases all but the first element
from every consecutive group of equivalent elements[.](#operations-8.sentence-1)

That is, for a nonempty hive,
erases all elements referred to by the iterator i in the range [begin() + 1, end())
for which binary_pred(*i, *(i - 1)) is true[.](#operations-8.sentence-2)

[9](#operations-9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8859)

*Returns*: The number of elements erased[.](#operations-9.sentence-1)

[10](#operations-10)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8863)

*Throws*: Nothing unless an exception is thrown by the predicate[.](#operations-10.sentence-1)

[11](#operations-11)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8867)

*Complexity*: If empty() is false,
exactly size() - 1 applications of the corresponding predicate,
otherwise no applications of the predicate[.](#operations-11.sentence-1)

[12](#operations-12)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8873)

*Remarks*: Invalidates references, pointers, and iterators
referring to the erased elements[.](#operations-12.sentence-1)

If the last element in *this is erased,
also invalidates the past-the-end iterator[.](#operations-12.sentence-2)

[ð](#lib:sort,hive)

`template<class Compare = less<T>>
  void sort(Compare comp = Compare());
`

[13](#operations-13)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8888)

*Preconditions*: T is *Cpp17MoveInsertable* into hive,*Cpp17MoveAssignable*, and *Cpp17Swappable*[.](#operations-13.sentence-1)

[14](#operations-14)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8893)

*Effects*: Sorts *this according to the comp function object[.](#operations-14.sentence-1)

If an exception is thrown,
the order of the elements in *this is unspecified[.](#operations-14.sentence-2)

[15](#operations-15)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8899)

*Complexity*: O(NlogN) comparisons, where N is size()[.](#operations-15.sentence-1)

[16](#operations-16)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8903)

*Remarks*: May allocate[.](#operations-16.sentence-1)

References, pointers, and iterators referring to elements in *this,
as well as the past-the-end iterator, may be invalidated[.](#operations-16.sentence-2)

[*Note [1](#operations-note-1)*:

Not required to be stable[[algorithm.stable]](algorithm.stable "16.4.6.8 Requirements for stable algorithms")[.](#operations-16.sentence-3)

â *end note*]

[ð](#lib:get_iterator,hive)

`iterator get_iterator(const_pointer p) noexcept;
const_iterator get_iterator(const_pointer p) const noexcept;
`

[17](#operations-17)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8920)

*Preconditions*: p points to an element in *this[.](#operations-17.sentence-1)

[18](#operations-18)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8924)

*Returns*: An iterator or const_iterator pointing to the same element as p[.](#operations-18.sentence-1)

[19](#operations-19)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8929)

*Complexity*: Linear in the number of active blocks in *this[.](#operations-19.sentence-1)

#### [23.3.9.6](#erasure) Erasure [[hive.erasure]](hive.erasure)

[ð](#lib:erase,hive_)

`template<class T, class Allocator, class U = T>
  typename hive<T, Allocator>::size_type
    erase(hive<T, Allocator>& c, const U& value);
`

[1](#erasure-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8944)

*Effects*: Equivalent to:return erase_if(c, [&](const auto& elem) -> bool { return elem == value; });

[ð](#lib:erase_if,hive)

`template<class T, class Allocator, class Predicate>
  typename hive<T, Allocator>::size_type
    erase_if(hive<T, Allocator>& c, Predicate pred);
`

[2](#erasure-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8960)

*Effects*: Equivalent to:auto original_size = c.size();for (auto i = c.begin(), last = c.end(); i != last; ) {if (pred(*i)) { i = c.erase(i); } else {++i; }}return original_size - c.size();
