Namespaces
Variants

std::inplace_vector<T,N>:: capacity

From cppreference.net
static constexpr size_type capacity ( ) noexcept ;
(自 C++26 起)

返回内部(就地)存储的容量。等价于: return N ;

目录

参数

(无)

返回值

容器能够容纳的最大元素数量。

复杂度

常量。

注释

由于每个 std:: inplace_vector < T, N > 都是固定容量容器, capacity 返回的值等于 N (该值同时也是 max_size() 的返回值)。

示例

#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);
}

参见

[static]
返回可能容纳的最大元素数
(公开静态成员函数)
返回容纳的元素数
(公开成员函数)
更改存储的元素数量
(公开成员函数)
检查容器是否为空
(公开成员函数)
[static]
预留存储空间
(公开静态成员函数)