list_empty
list_empty (std::list::empty — 비어 있는지 확인)
std::list에 원소가 없는지 확인하는 멤버 함수예요. begin() == end()인지와 동등한 판정을 해요.
출처: cppreference
본문
시그니처는 다음과 같아요.
bool empty() const noexcept; // (since C++11)
컨테이너에 원소가 없는지, 즉 begin() == end()인지 확인해요.
반환값
컨테이너가 비어 있으면 true, 아니면 false.
복잡도
상수(constant)예요.
예제
#include <list>
#include <iostream>
int main()
{
std::list<int> numbers;
std::cout << std::boolalpha;
std::cout << "Initially, numbers.empty(): " << numbers.empty() << '\n';
numbers.push_back(42);
std::cout << "After adding an element, numbers.empty(): " << numbers.empty() << '\n';
}