iterator_traits

Minjun_·2022년 8월 15일

C++

목록 보기
3/5
post-thumbnail

iterator_traits

template <class Iterator> class iterator_traits;
template <class T> class iterator_traits<T*>;
template <class T> class iterator_traits<const T*>;

Iterator의 특성을 나타내는 Traits(특성) Class

Standard Algorithm은 iterator_traits 인스턴스화의 Member를 이용하여 전달된 Iterator의 속성과 범위를 결정한다.

모든 Iterator type에 대해서 iterator_traits 클래스의 템플릿은 최소한 다음 멤버 유형이 정의되어야 한다.

memberdescription
difference_typeType to express the result of subtracting one iterator from another.
value_typeThe type of the element the iterator can point to
pointerThe type of a pointer to an element the iterator can point to.
referenceThe type of a reference to an element the iterator can point to
iterator_categoryThe iterator category.

iterator category

  • input_iterator_tag
  • output_iterator_tag
  • forward_iterator_tag
  • bidirectional_iterator_tag
  • random_access_iterator_tag
profile
졸음을 이겨내자..!

0개의 댓글