<array>, <deque>, <flat_map>, <flat_set>, <forward_list>, <inplace_vector>, <iterator>, <list>, <map>, <regex>, <set>, <span>, <string>, <string_view>, <unordered_map>, <unordered_set>, <vector>
C++17 ~
template<class C>
constexpr auto epmty(const C& c)->decltype(c.empty());
template<class T, std::size_t N>
constexpr bool empty(const T (&array)[N]) noexcept;
template<class E>
constexpr bool empty(std::initializer_list<E> il) noexcept;
: 주어진 범위가 비어있는지 확인합니다. 비어있으면 true, 비어있지 않으면 false를 반환합니다.
<example>
#include <iostream>
#include <vector>
using namespace std;
int main() {
vector<int> vec;
cout << vec.empty();
int a[50];
cout << empty(a); // 가비지 데이터가 들어가서 false를 반환
cout << empty({ 1, 2 });
return 0;
}
결과값
