std::vector::empty(3)
π std::vector::empty(3) π
okay so bestie, this page is from the C++ Standard Libary manual β yes, that's the manual name, typo and all, and we are not fixing it π
. It's the std::vector::empty(3) page, and it's literally about checking if a vector has no elements.
πΈ NAME πΈ
std::vector::empty β std::vector::empty
it's giving "same name, same energy," and honestly that's iconic. no cap.
β¨ Synopsis β¨
here's the signature, bestie β keep the const, the noexcept, and the constexpr exactly where they are:
bool empty() const; (noexcept since C++11)
(constexpr since C++20)
so it checks if the container has no elements, i.e. whether begin() == end(). that's the whole vibe check π₯.
π Parameters π
(none) β literally none, bestie. not a single parameter in sight π.
π¦ Return value π¦
true if the container is empty, false otherwise. periodt. π
β Complexity β
Constant. that's the whole note. iconic.
π Example π
// Run this code
#include <vector>
#include <iostream>
int main()
{
std::cout << std::boolalpha;
std::vector<int> numbers;
std::cout << "Initially, numbers.empty(): " << numbers.empty() <<
'\n';
numbers.push_back(42);
std::cout << "After adding elements, numbers.empty(): " <<
numbers.empty() << '\n';
}
π Output: π
Initially, numbers.empty(): true
After adding elements, numbers.empty(): false
π See also π
sizeβ returns the number of elements (public member function)emptyβ checks whether the container is empty (C++17) (function template)
that's the whole page, bestie π«Ά β source: http://cppreference.com, date: 2024.06.10, and the page is std::vector::empty(3). mwah πβ¨
π¦ 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