distance

distance (요소 사이 거리)

std::distance()은 두 반복자 사이의 요소 개수를 돌려줘요.

출처: cppreference

본문

std::distance는 반복자 first부터 last까지의 거리를 반환해요.

template< class InputIt >
typename std::iterator_traits<InputIt>::difference_type
    distance( InputIt first, InputIt last );

랜덤 접근 반복자면 뺄셈을, 아니면 순회하며 세요.

더 알아보기 (Learn more)

cppreference