-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiterator_traits.hpp
44 lines (40 loc) · 1.18 KB
/
iterator_traits.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#pragma once
//#include "iterator.hpp"
//#include "vector.hpp"
//?https://www.codeproject.com/Articles/36530/An-Introduction-to-Iterator-Traits
//?https://en.cppreference.com/w/cpp/iterator/iterator_traits
//?https://www.fluentcpp.com/2018/05/08/std-iterator-deprecated/
//?https://www.cplusplus.com/reference/iterator/iterator_traits/
namespace ft
{
template <class Iterator>
class iterator_traits
{
public:
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*>
{
public:
typedef ptrdiff_t difference_type;
typedef T value_type;
typedef T* pointer;
typedef T& reference;
typedef typename std::random_access_iterator_tag iterator_category;
};
template <class T>
class iterator_traits<const T*>
{
public:
typedef ptrdiff_t difference_type;
typedef T value_type;
typedef const T* pointer;
typedef const T& reference;
typedef typename std::random_access_iterator_tag iterator_category;
};
}