std::array::empty(3)
π¦ std::array::empty(3) π¦
okay so bestie, this is the C++ Standard Libary manual page for std::array::empty β and yes, the manual name is spelled βLibaryβ up there, so weβre keeping that energy exactly π
.
β¨ NAME β¨
std::array::empty - std::array::empty β iconic, redundant, we love her π.
π Synopsis π
constexpr bool empty() const noexcept; (since C++11)
(until C++20)
[[nodiscard]] constexpr bool empty() const noexcept; (since C++20)
This oneβs checking if the container has no elements, i.e. whether begin() == end() π.
π«Ά Parameters π«Ά
- (none) β literally no parameters here, bestie. not a single one π.
π Return value π
true if the container is empty, false otherwise. thatβs the whole tea π.
β‘ Complexity β‘
Constant. no cap, constant complexity β¨.
π 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 << std::boolalpha;
std::cout << "numbers.empty(): " << numbers.empty() << '\n';
std::cout << "no_numbers.empty(): " << no_numbers.empty() << '\n';
}
Output:
numbers.empty(): false
no_numbers.empty(): true
π See also π
sizeβ returns the number of elements (public member function) πΈ.emptyβ checks whether the container is empty (C++17) (function template) π¦.
mwah π this page is from http://cppreference.com, version/date 2024.06.10, and its title is std::array::empty(3) β go off and stay iconic ππ.
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms