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

> C++ Atlas: `cppatlas.com/w/cpp/container/inplace_vector/capacity` | Source: https://en.cppreference.com/w/cpp/container/inplace_vector/capacity | Domain: Containers | Standards: C++26

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

## Official Specification Summary (cppreference)

```cpp
static constexpr size_type capacity() noexcept; // (since C++26)
```

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

### Parameters

(none)

### Return value

The maximum number of elements the container is able to hold.

### Complexity

Constant.

### 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()`).

### Example

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

### See also

- [`max_size`](https://en.cppreference.com/w/cpp/container/inplace_vector/max_size) [static]: returns the maximum possible number of elements (public static member function)
- [`size`](https://en.cppreference.com/w/cpp/container/inplace_vector/size): returns the number of elements (public member function)
- [`resize`](https://en.cppreference.com/w/cpp/container/inplace_vector/resize): changes the number of elements stored (public member function)
- [`empty`](https://en.cppreference.com/w/cpp/container/inplace_vector/empty): checks whether the container is empty (public member function)
- [`reserve`](https://en.cppreference.com/w/cpp/container/inplace_vector/reserve) [static]: reserves storage (public static member function)

---
Attribution: content from https://en.cppreference.com/w/cpp/container/inplace_vector/capacity (cppreference.com), licensed under CC-BY-SA 3.0 and GFDL. Modified: converted to markdown, study notes added. Offline snapshot of 9 February 2025.