[C++ STL] iterator_traits

오젼·2022년 9월 4일
0

[C++ STL]

목록 보기
10/11

template <class Iterator>
class iterator_traits
{
	typedef typename Iterator::difference_type difference_type;
	typedef typename Iterator::value_type value_type;
	typedef typename Iterator::pointer pointer;
	typedef typename Iterator::reference reference;
	typedef typename Iterator::iterator_category iterator_category;
};

template <class T>
class iterator_traits<T *>
{
	typedef typename std::ptrdiff_t difference_type;
	typedef T value_type;
	typedef T *pointer;
	typedef T &reference;
	typedef typename ft::random_access_iterator_tag iterator_category;
};

template <class T>
class iterator_traits<const T *>
{
	typedef typename std::ptrdiff_t difference_type;
	typedef T value_type;
	typedef const T *pointer;
	typedef const T &reference;
	typedef typename ft::random_access_iterator_tag iterator_category;
};

0개의 댓글