std::deque::empty(3)
std::deque::empty(3)
okay bestie, this is from the C++ Standard Libary manual, and we're talking about std::deque::empty β the tiny little βis my deque empty?β check. No cap, itβs a whole mood. β¨
π NAME π
std::deque::empty β std::deque::empty
yep, thatβs the whole name. Short, iconic, to the point. π
β¨ Synopsis β¨
bool empty() const; (until C++11)
bool empty() const noexcept; (since C++11)
(until C++20)
[[nodiscard]] bool empty() const noexcept; (since C++20)
Checks if the container has no elements, i.e. whether begin() == end().
The version tags are literally part of the synopsis, bestie β(until C++11),(since C++11),(until C++20), and(since C++20)are all doing their own little era-defining thing. π
π Parameters π
(none) β zero arguments. Not a single one. Itβs giving low-maintenance. π«Ά
π Return value π
true if the container is empty, false otherwise.
β Complexity β
Constant.
π Example π
The following code uses empty to check if a std::deque<int> contains any elements:
// Run this code
#include <deque>
#include <iostream>
int main()
{
std::deque<int> numbers;
std::cout << std::boolalpha;
std::cout << "Initially, numbers.empty(): " << numbers.empty() << '\n';
numbers.push_back(42);
numbers.push_back(13317);
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)
made with π from http://cppreference.com, page dated 2024.06.10, title std::deque::empty(3) β catch u later bestie π«Ά
π¦ 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