Files
2025-10-25 03:02:53 +03:00

104 lines
2.8 KiB
Markdown

[inplace.vector.capacity]
# 23 Containers library [[containers]](./#containers)
## 23.3 Sequence containers [[sequences]](sequences#inplace.vector.capacity)
### 23.3.16 Class template inplace_vector [[inplace.vector]](inplace.vector#capacity)
#### 23.3.16.3 Capacity [inplace.vector.capacity]
[🔗](#lib:capacity,inplace_vector)
`static constexpr size_type capacity() noexcept;
static constexpr size_type max_size() noexcept;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11001)
*Returns*: N[.](#1.sentence-1)
[🔗](#lib:resize,inplace_vector)
`constexpr void resize(size_type sz);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11012)
*Preconditions*: T is *Cpp17DefaultInsertable* into inplace_vector[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11016)
*Effects*: If sz < size(),
erases the last size() - sz elements from the sequence[.](#3.sentence-1)
Otherwise,
appends sz - size() default-inserted elements to the sequence[.](#3.sentence-2)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11024)
*Remarks*: If an exception is thrown, there are no effects on *this[.](#4.sentence-1)
[🔗](#lib:resize,inplace_vector_)
`constexpr void resize(size_type sz, const T& c);
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11035)
*Preconditions*: T is *Cpp17CopyInsertable* into inplace_vector[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11039)
*Effects*: If sz < size(),
erases the last size() - sz elements from the sequence[.](#6.sentence-1)
Otherwise,
appends sz - size() copies of c to the sequence[.](#6.sentence-2)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11047)
*Remarks*: If an exception is thrown, there are no effects on *this[.](#7.sentence-1)
[🔗](#lib:reserve,inplace_vector)
`static constexpr void reserve(size_type n);
`
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11058)
*Effects*: None[.](#8.sentence-1)
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11062)
*Throws*: bad_alloc if n > capacity() is true[.](#9.sentence-1)
[🔗](#lib:shrink_to_fit,inplace_vector)
`static constexpr void shrink_to_fit() noexcept;
`
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11073)
*Effects*: None[.](#10.sentence-1)