Namespaces
Variants
Actions

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

From cppreference.com
 
C++
 
Containers library
 
std::inplace_vector
static constexpr size_type capacity() noexcept;
(since C++26)

Returns the capacity of the internal (inplace) storage. Equivalent to: return N;.

Contents

[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

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

[edit] See also

[static]
returns the maximum possible number of elements
(public static member function) [edit]
returns the number of elements
(public member function) [edit]
changes the number of elements stored
(public member function) [edit]
checks whether the container is empty
(public member function) [edit]
[static]
reserves storage
(public static member function) [edit]

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant