Init
This commit is contained in:
261
cppdraft/hive/capacity.md
Normal file
261
cppdraft/hive/capacity.md
Normal file
@@ -0,0 +1,261 @@
|
||||
[hive.capacity]
|
||||
|
||||
# 23 Containers library [[containers]](./#containers)
|
||||
|
||||
## 23.3 Sequence containers [[sequences]](sequences#hive.capacity)
|
||||
|
||||
### 23.3.9 Class template hive [[hive]](hive#capacity)
|
||||
|
||||
#### 23.3.9.3 Capacity [hive.capacity]
|
||||
|
||||
[ð](#lib:capacity,hive)
|
||||
|
||||
`size_type capacity() const noexcept;
|
||||
`
|
||||
|
||||
[1](#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[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8438)
|
||||
|
||||
*Complexity*: Constant[.](#2.sentence-1)
|
||||
|
||||
[ð](#lib:reserve,hive)
|
||||
|
||||
`void reserve(size_type n);
|
||||
`
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8449)
|
||||
|
||||
*Effects*: If n <= capacity() is true, there are no effects[.](#3.sentence-1)
|
||||
|
||||
Otherwise increases capacity() by allocating reserved blocks[.](#3.sentence-2)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8454)
|
||||
|
||||
*Postconditions*: capacity() >= n is true[.](#4.sentence-1)
|
||||
|
||||
[5](#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[.](#5.sentence-1)
|
||||
|
||||
[6](#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[.](#6.sentence-1)
|
||||
|
||||
[7](#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[.](#7.sentence-1)
|
||||
|
||||
[ð](#lib:shrink_to_fit,hive)
|
||||
|
||||
`void shrink_to_fit();
|
||||
`
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8480)
|
||||
|
||||
*Preconditions*: T is *Cpp17MoveInsertable* into hive[.](#8.sentence-1)
|
||||
|
||||
[9](#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()[.](#9.sentence-1)
|
||||
|
||||
[*Note [1](#note-1)*:
|
||||
|
||||
The request is non-binding
|
||||
to allow latitude for implementation-specific optimizations[.](#9.sentence-2)
|
||||
|
||||
â *end note*]
|
||||
|
||||
It does not increase capacity(), but may reduce capacity()[.](#9.sentence-3)
|
||||
|
||||
It may reallocate elements[.](#9.sentence-4)
|
||||
|
||||
If capacity() is already equal to size(), there are no effects[.](#9.sentence-5)
|
||||
|
||||
If an exception is thrown during allocation of a new element block,capacity() may be reduced and reallocation may occur[.](#9.sentence-6)
|
||||
|
||||
Otherwise if an exception is thrown, the effects are unspecified[.](#9.sentence-7)
|
||||
|
||||
[10](#10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8499)
|
||||
|
||||
*Complexity*: If reallocation happens, linear in the size of the sequence[.](#10.sentence-1)
|
||||
|
||||
[11](#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[.](#11.sentence-1)
|
||||
|
||||
[ð](#lib:trim_capacity,hive)
|
||||
|
||||
`void trim_capacity() noexcept;
|
||||
void trim_capacity(size_type n) noexcept;
|
||||
`
|
||||
|
||||
[12](#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[.](#12.sentence-1)
|
||||
|
||||
For the second overload, capacity() is reduced to no less than n[.](#12.sentence-2)
|
||||
|
||||
[13](#13)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8525)
|
||||
|
||||
*Complexity*: Linear in the number of reserved blocks deallocated[.](#13.sentence-1)
|
||||
|
||||
[14](#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[.](#14.sentence-1)
|
||||
|
||||
[ð](#lib:block_capacity_limits,hive)
|
||||
|
||||
`constexpr hive_limits block_capacity_limits() const noexcept;
|
||||
`
|
||||
|
||||
[15](#15)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8541)
|
||||
|
||||
*Returns*: *current-limits*[.](#15.sentence-1)
|
||||
|
||||
[16](#16)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8545)
|
||||
|
||||
*Complexity*: Constant[.](#16.sentence-1)
|
||||
|
||||
[ð](#lib:block_capacity_default_limits,hive)
|
||||
|
||||
`static constexpr hive_limits block_capacity_default_limits() noexcept;
|
||||
`
|
||||
|
||||
[17](#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[.](#17.sentence-1)
|
||||
|
||||
[18](#18)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8562)
|
||||
|
||||
*Complexity*: Constant[.](#18.sentence-1)
|
||||
|
||||
[ð](#lib:block_capacity_hard_limits,hive)
|
||||
|
||||
`static constexpr hive_limits block_capacity_hard_limits() noexcept;
|
||||
`
|
||||
|
||||
[19](#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[.](#19.sentence-1)
|
||||
|
||||
[20](#20)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8579)
|
||||
|
||||
*Complexity*: Constant[.](#20.sentence-1)
|
||||
|
||||
[ð](#lib:reshape,hive)
|
||||
|
||||
`void reshape(hive_limits block_limits);
|
||||
`
|
||||
|
||||
[21](#21)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8590)
|
||||
|
||||
*Preconditions*: T is *Cpp17MoveInsertable* into hive[.](#21.sentence-1)
|
||||
|
||||
[22](#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[.](#22.sentence-1)
|
||||
|
||||
Any element blocks not within the bounds of block_limits are deallocated[.](#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[.](#22.sentence-3)
|
||||
|
||||
Otherwise block_limits is assigned to *current-limits*[.](#22.sentence-4)
|
||||
|
||||
If any other exception is thrown the effects are unspecified[.](#22.sentence-5)
|
||||
|
||||
[23](#23)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8609)
|
||||
|
||||
*Postconditions*: size() is unchanged[.](#23.sentence-1)
|
||||
|
||||
[24](#24)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8613)
|
||||
|
||||
*Complexity*: Linear in the number of element blocks in *this[.](#24.sentence-1)
|
||||
|
||||
If reallocation happens, also linear in the number of elements reallocated[.](#24.sentence-2)
|
||||
|
||||
[25](#25)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8618)
|
||||
|
||||
*Remarks*: This operation may change capacity()[.](#25.sentence-1)
|
||||
|
||||
If reallocation happens, the order of the elements in *this may change[.](#25.sentence-2)
|
||||
|
||||
Reallocation invalidates all references, pointers, and iterators
|
||||
referring to the elements in *this,
|
||||
as well as the past-the-end iterator[.](#25.sentence-3)
|
||||
|
||||
[*Note [2](#note-2)*:
|
||||
|
||||
If no reallocation happens, they remain valid[.](#25.sentence-4)
|
||||
|
||||
â *end note*]
|
||||
330
cppdraft/hive/cons.md
Normal file
330
cppdraft/hive/cons.md
Normal file
@@ -0,0 +1,330 @@
|
||||
[hive.cons]
|
||||
|
||||
# 23 Containers library [[containers]](./#containers)
|
||||
|
||||
## 23.3 Sequence containers [[sequences]](sequences#hive.cons)
|
||||
|
||||
### 23.3.9 Class template hive [[hive]](hive#cons)
|
||||
|
||||
#### 23.3.9.2 Constructors, copy, and assignment [hive.cons]
|
||||
|
||||
[ð](#lib:hive,constructor)
|
||||
|
||||
`constexpr explicit hive(const Allocator&) noexcept;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8139)
|
||||
|
||||
*Effects*: Constructs an empty hive, using the specified allocator[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8143)
|
||||
|
||||
*Complexity*: Constant[.](#2.sentence-1)
|
||||
|
||||
[ð](#lib:hive,constructor_)
|
||||
|
||||
`constexpr hive(hive_limits block_limits, const Allocator&);
|
||||
`
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8154)
|
||||
|
||||
*Effects*: Constructs an empty hive, using the specified allocator[.](#3.sentence-1)
|
||||
|
||||
Initializes *current-limits* with block_limits[.](#3.sentence-2)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8159)
|
||||
|
||||
*Complexity*: Constant[.](#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](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8171)
|
||||
|
||||
*Preconditions*: T is *Cpp17DefaultInsertable* into hive[.](#5.sentence-1)
|
||||
|
||||
[6](#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[.](#6.sentence-1)
|
||||
|
||||
If the second overload is called,
|
||||
also initializes *current-limits* with block_limits[.](#6.sentence-2)
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8182)
|
||||
|
||||
*Complexity*: Linear in n[.](#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](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8194)
|
||||
|
||||
*Preconditions*: T is *Cpp17CopyInsertable* into hive[.](#8.sentence-1)
|
||||
|
||||
[9](#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[.](#9.sentence-1)
|
||||
|
||||
If the second overload is called,
|
||||
also initializes *current-limits* with block_limits[.](#9.sentence-2)
|
||||
|
||||
[10](#10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8205)
|
||||
|
||||
*Complexity*: Linear in n[.](#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](#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[.](#11.sentence-1)
|
||||
|
||||
If the second overload is called,
|
||||
also initializes *current-limits* with block_limits[.](#11.sentence-2)
|
||||
|
||||
[12](#12)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8227)
|
||||
|
||||
*Complexity*: Linear in distance(first, last)[.](#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](#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[.](#13.sentence-1)
|
||||
|
||||
If the second overload is called,
|
||||
also initializes *current-limits* with block_limits[.](#13.sentence-2)
|
||||
|
||||
[14](#14)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8248)
|
||||
|
||||
*Complexity*: Linear in ranges::distance(rg)[.](#14.sentence-1)
|
||||
|
||||
[ð](#lib:hive,constructor______)
|
||||
|
||||
`hive(const hive& x);
|
||||
hive(const hive& x, const type_identity_t<Allocator>& alloc);
|
||||
`
|
||||
|
||||
[15](#15)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8260)
|
||||
|
||||
*Preconditions*: T is *Cpp17CopyInsertable* into hive[.](#15.sentence-1)
|
||||
|
||||
[16](#16)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8264)
|
||||
|
||||
*Effects*: Constructs a hive object with the elements of x[.](#16.sentence-1)
|
||||
|
||||
If the second overload is called, uses alloc[.](#16.sentence-2)
|
||||
|
||||
Initializes *current-limits* with x.*current-limits*[.](#16.sentence-3)
|
||||
|
||||
[17](#17)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8270)
|
||||
|
||||
*Complexity*: Linear in x.size()[.](#17.sentence-1)
|
||||
|
||||
[ð](#lib:hive,constructor_______)
|
||||
|
||||
`hive(hive&& x) noexcept;
|
||||
hive(hive&& x, const type_identity_t<Allocator>& alloc);
|
||||
`
|
||||
|
||||
[18](#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[.](#18.sentence-1)
|
||||
|
||||
[19](#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[.](#19.sentence-1)
|
||||
|
||||
Pointers and references to the elements of x now refer to
|
||||
those same elements but as members of *this[.](#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[.](#19.sentence-3)
|
||||
|
||||
If the second overload is called andalloc == x.get_allocator() is false,
|
||||
each element in x is moved into *this[.](#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[.](#19.sentence-5)
|
||||
|
||||
[20](#20)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8306)
|
||||
|
||||
*Postconditions*: x.empty() is true[.](#20.sentence-1)
|
||||
|
||||
[21](#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()[.](#21.sentence-1)
|
||||
|
||||
Otherwise constant[.](#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](#22)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8324)
|
||||
|
||||
*Preconditions*: T is *Cpp17CopyInsertable* into hive[.](#22.sentence-1)
|
||||
|
||||
[23](#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[.](#23.sentence-1)
|
||||
|
||||
If the second overload is called,
|
||||
also initializes *current-limits* with block_limits[.](#23.sentence-2)
|
||||
|
||||
[24](#24)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8335)
|
||||
|
||||
*Complexity*: Linear in il.size()[.](#24.sentence-1)
|
||||
|
||||
[ð](#lib:operator=,hive)
|
||||
|
||||
`hive& operator=(const hive& x);
|
||||
`
|
||||
|
||||
[25](#25)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8346)
|
||||
|
||||
*Preconditions*: T is *Cpp17CopyInsertable* into hive and*Cpp17CopyAssignable*[.](#25.sentence-1)
|
||||
|
||||
[26](#26)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8351)
|
||||
|
||||
*Effects*: All elements in *this are either copy-assigned to, or destroyed[.](#26.sentence-1)
|
||||
|
||||
All elements in x are copied into *this[.](#26.sentence-2)
|
||||
|
||||
[*Note [1](#note-1)*:
|
||||
|
||||
*current-limits* is unchanged[.](#26.sentence-3)
|
||||
|
||||
â *end note*]
|
||||
|
||||
[27](#27)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8359)
|
||||
|
||||
*Complexity*: Linear in size() + x.size()[.](#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](#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*[.](#28.sentence-1)
|
||||
|
||||
[29](#29)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8383)
|
||||
|
||||
*Effects*: Each element in *this is either move-assigned to, or destroyed[.](#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[.](#29.sentence-2)
|
||||
|
||||
Pointers and references to the elements of x now refer to those same elements but as members of *this[.](#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[.](#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[.](#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[.](#29.sentence-6)
|
||||
|
||||
[30](#30)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8410)
|
||||
|
||||
*Postconditions*: x.empty() is true[.](#30.sentence-1)
|
||||
|
||||
[31](#31)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8414)
|
||||
|
||||
*Complexity*: Linear in size()[.](#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()[.](#31.sentence-2)
|
||||
35
cppdraft/hive/erasure.md
Normal file
35
cppdraft/hive/erasure.md
Normal file
@@ -0,0 +1,35 @@
|
||||
[hive.erasure]
|
||||
|
||||
# 23 Containers library [[containers]](./#containers)
|
||||
|
||||
## 23.3 Sequence containers [[sequences]](sequences#hive.erasure)
|
||||
|
||||
### 23.3.9 Class template hive [[hive]](hive#erasure)
|
||||
|
||||
#### 23.3.9.6 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](#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](#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();
|
||||
201
cppdraft/hive/modifiers.md
Normal file
201
cppdraft/hive/modifiers.md
Normal file
@@ -0,0 +1,201 @@
|
||||
[hive.modifiers]
|
||||
|
||||
# 23 Containers library [[containers]](./#containers)
|
||||
|
||||
## 23.3 Sequence containers [[sequences]](sequences#hive.modifiers)
|
||||
|
||||
### 23.3.9 Class template hive [[hive]](hive#modifiers)
|
||||
|
||||
#### 23.3.9.4 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](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8639)
|
||||
|
||||
*Preconditions*: T is *Cpp17EmplaceConstructible* into hive from args[.](#1.sentence-1)
|
||||
|
||||
[2](#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)...[.](#2.sentence-1)
|
||||
|
||||
The hint parameter is ignored[.](#2.sentence-2)
|
||||
|
||||
If an exception is thrown, there are no effects[.](#2.sentence-3)
|
||||
|
||||
[*Note [1](#note-1)*:
|
||||
|
||||
args can directly or indirectly refer to a value in *this[.](#2.sentence-4)
|
||||
|
||||
â *end note*]
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8653)
|
||||
|
||||
*Returns*: An iterator that points to the new element[.](#3.sentence-1)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8657)
|
||||
|
||||
*Complexity*: Constant[.](#4.sentence-1)
|
||||
|
||||
Exactly one object of type T is constructed[.](#4.sentence-2)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8661)
|
||||
|
||||
*Remarks*: Invalidates the past-the-end iterator[.](#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](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8675)
|
||||
|
||||
*Effects*: Equivalent to: return emplace(std::forward<decltype(x)>(x));
|
||||
|
||||
[*Note [2](#note-2)*:
|
||||
|
||||
The hint parameter is ignored[.](#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](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8691)
|
||||
|
||||
*Preconditions*: T is *Cpp17EmplaceInsertable* into hive from *ranges::begin(rg)[.](#7.sentence-1)
|
||||
|
||||
rg and *this do not overlap[.](#7.sentence-2)
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8697)
|
||||
|
||||
*Effects*: Inserts copies of elements in rg[.](#8.sentence-1)
|
||||
|
||||
Each iterator in the range rg is dereferenced exactly once[.](#8.sentence-2)
|
||||
|
||||
[9](#9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8702)
|
||||
|
||||
*Complexity*: Linear in the number of elements inserted[.](#9.sentence-1)
|
||||
|
||||
Exactly one object of type T is constructed for each element inserted[.](#9.sentence-2)
|
||||
|
||||
[10](#10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8707)
|
||||
|
||||
*Remarks*: If an element is inserted, invalidates the past-the-end iterator[.](#10.sentence-1)
|
||||
|
||||
[ð](#lib:insert,hive__)
|
||||
|
||||
`void insert(size_type n, const T& x);
|
||||
`
|
||||
|
||||
[11](#11)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8718)
|
||||
|
||||
*Preconditions*: T is *Cpp17CopyInsertable* into hive[.](#11.sentence-1)
|
||||
|
||||
[12](#12)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8722)
|
||||
|
||||
*Effects*: Inserts n copies of x[.](#12.sentence-1)
|
||||
|
||||
[13](#13)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8726)
|
||||
|
||||
*Complexity*: Linear in n[.](#13.sentence-1)
|
||||
|
||||
Exactly one object of type T is constructed for each element inserted[.](#13.sentence-2)
|
||||
|
||||
[14](#14)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8731)
|
||||
|
||||
*Remarks*: If an element is inserted, invalidates the past-the-end iterator[.](#14.sentence-1)
|
||||
|
||||
[ð](#lib:insert,hive___)
|
||||
|
||||
`template<class InputIterator>
|
||||
void insert(InputIterator first, InputIterator last);
|
||||
`
|
||||
|
||||
[15](#15)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8743)
|
||||
|
||||
*Effects*: Equivalent to insert_range(ranges::subrange(first, last))[.](#15.sentence-1)
|
||||
|
||||
[ð](#lib:erase,hive)
|
||||
|
||||
`iterator erase(const_iterator position);
|
||||
iterator erase(const_iterator first, const_iterator last);
|
||||
`
|
||||
|
||||
[16](#16)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8755)
|
||||
|
||||
*Complexity*: Linear in the number of elements erased[.](#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[.](#16.sentence-2)
|
||||
|
||||
[17](#17)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8762)
|
||||
|
||||
*Remarks*: Invalidates references, pointers and iterators
|
||||
referring to the erased elements[.](#17.sentence-1)
|
||||
|
||||
An erase operation that erases the last element in *this also invalidates the past-the-end iterator[.](#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](#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[.](#18.sentence-1)
|
||||
|
||||
[19](#19)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8783)
|
||||
|
||||
*Complexity*: Constant[.](#19.sentence-1)
|
||||
191
cppdraft/hive/operations.md
Normal file
191
cppdraft/hive/operations.md
Normal file
@@ -0,0 +1,191 @@
|
||||
[hive.operations]
|
||||
|
||||
# 23 Containers library [[containers]](./#containers)
|
||||
|
||||
## 23.3 Sequence containers [[sequences]](sequences#hive.operations)
|
||||
|
||||
### 23.3.9 Class template hive [[hive]](hive#operations)
|
||||
|
||||
#### 23.3.9.5 Operations [hive.operations]
|
||||
|
||||
[1](#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")[.](#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[.](#1.sentence-2)
|
||||
|
||||
For sort, the definitions and requirements in [[alg.sorting]](alg.sorting "26.8 Sorting and related operations") apply[.](#1.sentence-3)
|
||||
|
||||
[ð](#lib:splice,hive)
|
||||
|
||||
`void splice(hive& x);
|
||||
void splice(hive&& x);
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8807)
|
||||
|
||||
*Preconditions*: get_allocator() == x.get_allocator() is true[.](#2.sentence-1)
|
||||
|
||||
[3](#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[.](#3.sentence-1)
|
||||
|
||||
Otherwise, inserts the contents of x into *this andx becomes empty[.](#3.sentence-2)
|
||||
|
||||
Pointers and references to the moved elements of x now refer to those same elements but as members of *this[.](#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[.](#3.sentence-4)
|
||||
|
||||
[4](#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*[.](#4.sentence-1)
|
||||
|
||||
[5](#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[.](#5.sentence-1)
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8832)
|
||||
|
||||
*Remarks*: Reserved blocks in x are not transferred into *this[.](#6.sentence-1)
|
||||
|
||||
If addressof(x) == this is false,
|
||||
invalidates the past-the-end iterator for both x and *this[.](#6.sentence-2)
|
||||
|
||||
[ð](#lib:unique,hive)
|
||||
|
||||
`template<class BinaryPredicate = equal_to<T>>
|
||||
size_type unique(BinaryPredicate binary_pred = BinaryPredicate());
|
||||
`
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8846)
|
||||
|
||||
*Preconditions*: binary_pred is an equivalence relation[.](#7.sentence-1)
|
||||
|
||||
[8](#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[.](#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[.](#8.sentence-2)
|
||||
|
||||
[9](#9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8859)
|
||||
|
||||
*Returns*: The number of elements erased[.](#9.sentence-1)
|
||||
|
||||
[10](#10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8863)
|
||||
|
||||
*Throws*: Nothing unless an exception is thrown by the predicate[.](#10.sentence-1)
|
||||
|
||||
[11](#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[.](#11.sentence-1)
|
||||
|
||||
[12](#12)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8873)
|
||||
|
||||
*Remarks*: Invalidates references, pointers, and iterators
|
||||
referring to the erased elements[.](#12.sentence-1)
|
||||
|
||||
If the last element in *this is erased,
|
||||
also invalidates the past-the-end iterator[.](#12.sentence-2)
|
||||
|
||||
[ð](#lib:sort,hive)
|
||||
|
||||
`template<class Compare = less<T>>
|
||||
void sort(Compare comp = Compare());
|
||||
`
|
||||
|
||||
[13](#13)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8888)
|
||||
|
||||
*Preconditions*: T is *Cpp17MoveInsertable* into hive,*Cpp17MoveAssignable*, and *Cpp17Swappable*[.](#13.sentence-1)
|
||||
|
||||
[14](#14)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8893)
|
||||
|
||||
*Effects*: Sorts *this according to the comp function object[.](#14.sentence-1)
|
||||
|
||||
If an exception is thrown,
|
||||
the order of the elements in *this is unspecified[.](#14.sentence-2)
|
||||
|
||||
[15](#15)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8899)
|
||||
|
||||
*Complexity*: O(NlogN) comparisons, where N is size()[.](#15.sentence-1)
|
||||
|
||||
[16](#16)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8903)
|
||||
|
||||
*Remarks*: May allocate[.](#16.sentence-1)
|
||||
|
||||
References, pointers, and iterators referring to elements in *this,
|
||||
as well as the past-the-end iterator, may be invalidated[.](#16.sentence-2)
|
||||
|
||||
[*Note [1](#note-1)*:
|
||||
|
||||
Not required to be stable[[algorithm.stable]](algorithm.stable "16.4.6.8 Requirements for stable algorithms")[.](#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](#17)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8920)
|
||||
|
||||
*Preconditions*: p points to an element in *this[.](#17.sentence-1)
|
||||
|
||||
[18](#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[.](#18.sentence-1)
|
||||
|
||||
[19](#19)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8929)
|
||||
|
||||
*Complexity*: Linear in the number of active blocks in *this[.](#19.sentence-1)
|
||||
161
cppdraft/hive/overview.md
Normal file
161
cppdraft/hive/overview.md
Normal file
@@ -0,0 +1,161 @@
|
||||
[hive.overview]
|
||||
|
||||
# 23 Containers library [[containers]](./#containers)
|
||||
|
||||
## 23.3 Sequence containers [[sequences]](sequences#hive.overview)
|
||||
|
||||
### 23.3.9 Class template hive [[hive]](hive#overview)
|
||||
|
||||
#### 23.3.9.1 Overview [hive.overview]
|
||||
|
||||
[1](#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[.](#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]")[.](#1.sentence-2)
|
||||
|
||||
Insertion position is determined by the container, and insertion
|
||||
may re-use the memory locations of erased elements[.](#1.sentence-3)
|
||||
|
||||
[2](#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]")[.](#2.sentence-1)
|
||||
|
||||
Active blocks which become empty of elements are
|
||||
either deallocated or become reserved blocks[.](#2.sentence-2)
|
||||
|
||||
Reserved blocks become active blocks when they are used to store elements[.](#2.sentence-3)
|
||||
|
||||
A user can create additional reserved blocks by calling reserve[.](#2.sentence-4)
|
||||
|
||||
[3](#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[.](#3.sentence-1)
|
||||
|
||||
[4](#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[.](#4.sentence-1)
|
||||
|
||||
[5](#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[.](#5.sentence-1)
|
||||
|
||||
- [(5.1)](#5.1)
|
||||
|
||||
The minimum limit shall be no larger than the maximum limit[.](#5.1.sentence-1)
|
||||
|
||||
- [(5.2)](#5.2)
|
||||
|
||||
When limits are not specified by a user during construction,
|
||||
the implementation's default limits are used[.](#5.2.sentence-1)
|
||||
|
||||
- [(5.3)](#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[.](#5.3.sentence-1)
|
||||
[*Note [1](#note-1)*:
|
||||
To allow latitude for
|
||||
both implementation-specific and user-directed optimization[.](#5.3.sentence-2)
|
||||
â *end note*]
|
||||
The latter are defined as hard limits[.](#5.3.sentence-3)
|
||||
The maximum hard limit shall be no larger thanstd::allocator_traits<Allocator>::max_size()[.](#5.3.sentence-4)
|
||||
|
||||
- [(5.4)](#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[.](#5.4.sentence-1)
|
||||
|
||||
- [(5.5)](#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[.](#5.5.sentence-1)
|
||||
|
||||
[6](#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 !=[.](#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"))[.](#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[.](#6.sentence-3)
|
||||
|
||||
[7](#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>[.](#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]](hive.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]](hive.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]](hive.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]](hive.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>;}
|
||||
14
cppdraft/hive/syn.md
Normal file
14
cppdraft/hive/syn.md
Normal file
@@ -0,0 +1,14 @@
|
||||
[hive.syn]
|
||||
|
||||
# 23 Containers library [[containers]](./#containers)
|
||||
|
||||
## 23.3 Sequence containers [[sequences]](sequences#hive.syn)
|
||||
|
||||
### 23.3.8 Header <hive> synopsis [hive.syn]
|
||||
|
||||
[ð](#header:%3chive%3e)
|
||||
|
||||
#include <initializer_list> // see [[initializer.list.syn]](initializer.list.syn "17.11.2 Header <initializer_list> synopsis")#include <compare> // see [[compare.syn]](compare.syn "17.12.1 Header <compare> synopsis")namespace std {struct [hive_limits](#lib:hive_limits "23.3.8 Header <hive> synopsis [hive.syn]") { size_t [min](#lib:hive_limits,min "23.3.8 Header <hive> synopsis [hive.syn]");
|
||||
size_t [max](#lib:hive_limits,max "23.3.8 Header <hive> synopsis [hive.syn]"); constexpr hive_limits(size_t minimum, size_t maximum) noexcept: min(minimum), max(maximum) {}}; // [[hive]](hive "23.3.9 Class template hive"), class template hivetemplate<class T, class Allocator = allocator<T>> class hive; template<class T, class Allocator>void swap(hive<T, Allocator>& x, hive<T, Allocator>& y)noexcept(noexcept(x.swap(y))); template<class T, class Allocator, class U = T>typename hive<T, Allocator>::size_type
|
||||
erase(hive<T, Allocator>& c, const U& value); template<class T, class Allocator, class Predicate>typename hive<T, Allocator>::size_type
|
||||
erase_if(hive<T, Allocator>& c, Predicate pred); namespace pmr {template<class T>using hive = std::hive<T, polymorphic_allocator<T>>; }}
|
||||
Reference in New Issue
Block a user