std::multimap<Key,T,Compare,Allocator>::empty
From ko.cppreference.net
bool empty() const;
|
(C++11부터 noexcept) | |
컨테이너에 요소가 없는지, 즉 begin() == end()인지 확인합니다.
반환값
true 컨테이너가 비어 있는 경우, false 그렇지 않은 경우.
복잡도
상수.
예제
다음 코드는
empty
를 사용하여
std::
multimap
<
int
,
int
>
에 요소가 있는지 확인합니다:
이 코드 실행
#include <iostream> #include <map> #include <utility> int main() { std::multimap<int,int> numbers; std::cout << std::boolalpha; std::cout << "Initially, numbers.empty(): " << numbers.empty() << '\n'; numbers.emplace(42, 13); numbers.insert(std::make_pair(13317, 123)); std::cout << "After adding elements, numbers.empty(): " << numbers.empty() << '\n'; }
출력:
Initially, numbers.empty(): true After adding elements, numbers.empty(): false
참고 항목
|
요소 수를 반환합니다
(public member function) |
|
|
(C++17)
|
컨테이너가 비어 있는지 확인합니다
(function template) |