Namespaces
Variants

std::ranges::transform_view<V,F>::size

cppreference.net에서
 
 
Ranges 라이브러리
Range 어댑터
 
 
constexpr auto size() requires ranges::sized_range<V>;
(1) (C++20부터)
constexpr auto size() const requires ranges::sized_range<const V>;
(2) (C++20부터)

요소의 개수를 반환합니다. ranges::size(base_)와 동일합니다.

반환값

요소의 개수.

참고 사항

만약 V 가 forward_range 를 모델하지 않는다면, size() 는 begin() 호출 이후에 제대로 정의되지 않을 수 있습니다.

예제

#include <cassert>
#include <cctype>
#include <iostream>
#include <ranges>
#include <string>
int main()
{
    std::string s{"The length of this string is 42 characters"};
    auto to_upper{[](unsigned char c) -> char { return std::toupper(c); }};
    auto tv{std::ranges::transform_view{s, to_upper}};
    for (assert(tv.size() == 42); const auto c : tv)
        std::cout << c;
}

출력:

THE LENGTH OF THIS STRING IS 42 CHARACTERS

참고 항목

범위의 크기와 같은 정수를 반환합니다
(customization point object)
범위의 크기와 같은 부호 있는 정수를 반환합니다
(customization point object)