std::vector::empty
cppreference.com
bool empty() const; |
( C++11) | |
bool empty() const noexcept; |
( C++11) ( C++20) |
|
[[nodiscard]] constexpr bool empty() const noexcept; |
( C++20) | |
, .. , begin() == end().
()
true , false .
.
#include <vector>
#include <iostream>
int main()
{
std::cout << std::boolalpha;
std::vector<int> numbers;
std::cout << " , numbers.empty(): " << numbers.empty() << '\n';
numbers.push_back(42);
std::cout << " , numbers.empty(): " << numbers.empty() << '\n';
}
:
, numbers.empty(): true
, numbers.empty(): false
See also
| (public -) |