std::array<T,N>::empty (3) - Linux Manuals
std::array<T,N>::empty: std::array<T,N>::empty
Command to display std::array<T,N>::empty
manual in Linux: $ man 3 std::array<T,N>::empty
NAME
std::array<T,N>::empty - std::array<T,N>::empty
Synopsis
constexpr bool empty() const noexcept; (since C++11)
(until C++20)
[[nodiscard]] constexpr bool empty() const noexcept; (since C++20)
Checks if the container has no elements, i.e. whether begin() == end().
Parameters
(none)
Return value
true if the container is empty, false otherwise
Complexity
Constant.
Example
The following code uses empty to check if a std::array contains any elements:
// Run this code
#include <array>
#include <iostream>
int main()
{
std::array<int, 4> numbers {3, 1, 4, 1};
std::array<int, 0> no_numbers;
std::cout << "numbers.empty(): " << numbers.empty() << '\n';
std::cout << "no_numbers.empty(): " << no_numbers.empty() << '\n';
}
Output:
numbers.empty(): 0
no_numbers.empty(): 1
See also
returns the number of elements
size (public member function)
Pages related to std::array<T,N>::empty
- std::array<T,N>::end,std::array<T,N>::cend (3) - std::array<T,N>::end,std::array<T,N>::cend
- std::array<T,N>::at (3) - std::array<T,N>::at
- std::array<T,N>::back (3) - std::array<T,N>::back
- std::array<T,N>::begin,std::array<T,N>::cbegin (3) - std::array<T,N>::begin,std::array<T,N>::cbegin
- std::array<T,N>::data (3) - std::array<T,N>::data
- std::array<T,N>::fill (3) - std::array<T,N>::fill
- std::array<T,N>::front (3) - std::array<T,N>::front
- std::array<T,N>::max_size (3) - std::array<T,N>::max_size
- std::array<T,N>::operator[] (3) - std::array<T,N>::operator[]
- std::array<T,N>::rbegin,std::array<T,N>::crbegin (3) - std::array<T,N>::rbegin,std::array<T,N>::crbegin
- std::array<T,N>::rend,std::array<T,N>::crend (3) - std::array<T,N>::rend,std::array<T,N>::crend
- std::array<T,N>::size (3) - std::array<T,N>::size
- std::array<T,N>::swap (3) - std::array<T,N>::swap
- std::array (3) - std::array