You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
2.4 KiB

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* iterator_traits.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: frdescam <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/12 18:23:48 by frdescam #+# #+# */
/* Updated: 2021/11/12 18:23:52 by frdescam ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef _ITERATOR_TRAIT_
#define _ITERATOR_TRAIT_
template<typename _Iterator>
struct iterator_traits
{
typedef typename _Iterator::iterator_category iterator_category;
typedef typename _Iterator::value_type value_type;
typedef typename _Iterator::difference_type difference_type;
typedef typename _Iterator::pointer pointer;
typedef typename _Iterator::reference reference;
};
template<typename _Tp>
struct iterator_traits<_Tp*>
{
typedef std::random_access_iterator_tag iterator_category;
typedef _Tp value_type;
typedef ptrdiff_t difference_type;
typedef _Tp* pointer;
typedef _Tp& reference;
};
template<typename _Tp>
struct iterator_traits<const _Tp*>
{
typedef std::random_access_iterator_tag iterator_category;
typedef _Tp value_type;
typedef ptrdiff_t difference_type;
typedef const _Tp* pointer;
typedef const _Tp& reference;
};
template <bool flag, class const_type, class normal_type>
struct choose_type;
template <class const_type, class normal_type>
struct choose_type<true, const_type, normal_type> {
typedef const_type type;
};
template <class const_type, class normal_type>
struct choose_type<false, const_type, normal_type> {
typedef normal_type type;
};
#endif