std::inplace_vector<T,N>::capacity
From cppreference.com
< cpp | container | inplace vector
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Containers library
(C++17)
(C++11)
(C++26)
(C++26)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++23)
(C++23)
(C++23)
(C++23)
(C++20)
(C++23)
Tables
std::inplace_vector
inplace_vector::capacity
static constexpr size_type capacity() noexcept;
(since C++26)
Returns the capacity of the internal (inplace) storage. Equivalent to: return N;.
[edit] Parameters
(none)
[edit] Return value
The maximum number of elements the container is able to hold.
[edit] Complexity
Constant.
[edit] Notes
Because each std::inplace_vector <T, N> is a fixed-capacity container, the value returned by capacity
equals N
(which is also the value returned by max_size()).
[edit] Example
Run this code
#include <inplace_vector> int main() { constexpr std::inplace_vector <int, 4> v1; static_assert(v1.capacity() == 4 && v1.max_size() == 4); constexpr std::inplace_vector <int, 0> v2; static_assert(v2.capacity() == 0 && v2.max_size() == 0); }