Namespaces
Variants

std::span<T,Extent>:: empty

From cppreference.net
constexpr bool empty ( ) const noexcept ;
(C++20부터)

스팬이 비어 있는지 확인합니다. 다음 코드와 동일합니다: return size ( ) == 0 ; .

반환값

true 스팬이 비어 있는 경우; false 그렇지 않은 경우.

예제

#include <iomanip>
#include <iostream>
#include <span>
int main()
{
    std::span<const char> span{"ABCDEF"};
    while (!span.empty())
    {
        std::cout << std::quoted(span.data()) << '\n';
        span = span.last(span.size() - 1);
    }
}

출력:

"ABCDEF"
"BCDEF"
"CDEF"
"DEF"
"EF"
"F"
""

참고 항목

(C++20)
시퀀스의 요소 개수를 반환합니다
(public member function)