Namespaces
Variants

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

From cppreference.net
constexpr size_type size ( ) const noexcept ;
(C++20 이후)

스팬의 요소 개수를 반환합니다.

목차

반환값

스팬 내 요소의 개수입니다.

참고

기능 테스트 매크로 표준 기능
__cpp_lib_ssize 201902L (C++20) std::ssize 및 부호 없는 std::span::size

예제

#include <span>
int main()
{
    constexpr static int c_array[]{1, 2, 3, 4, 5, 6, 7, 8};
    constexpr std::span<const int> span{c_array};
    static_assert(8 == span.size());
    static_assert(7 == span.first(7).size());
    static_assert(6 == span.first<6>().size());
    static_assert(5 == span.last(5).size());
    static_assert(4 == span.last<4>().size());
    static_assert(3 == span.subspan(2, 3).size());
    static_assert(2 == span.subspan<3, 2>().size());
    static_assert(1 == span.subspan<7>().size());
}

참고 항목

span 을 생성한다
(public member function)
시퀀스의 크기를 바이트 단위로 반환한다
(public member function)