10
10
11
11
#include < cstdint>
12
12
#include < deque>
13
+ #include < iterator>
14
+ #include < type_traits>
13
15
14
16
#include " min_allocator.h"
15
17
#include " test_allocator.h"
18
20
template <class T >
19
21
class small_pointer {
20
22
std::uint16_t offset;
23
+
24
+ public:
25
+ using value_type = typename std::remove_cv<T>::type;
26
+ using difference_type = std::int16_t ;
27
+ using reference = T&;
28
+ using pointer = T*;
29
+ using iterator_category = std::random_access_iterator_tag;
30
+
31
+ template <class CT ,
32
+ typename std::enable_if<std::is_same<const T, CT>::value && !std::is_const<T>::value, int >::type = 0 >
33
+ operator small_pointer<CT>() const ;
34
+ template <
35
+ class Void ,
36
+ typename std::enable_if<std::is_same<Void, void >::value && std::is_convertible<T*, void *>::value, int >::type = 0 >
37
+ operator small_pointer<Void>() const ;
38
+ template <
39
+ class CVoid ,
40
+ typename std::enable_if<std::is_same<CVoid, const void >::value && std::is_convertible<T*, const void *>::value,
41
+ int >::type = 0 >
42
+ operator small_pointer<CVoid>() const ;
43
+
44
+ T& operator *() const ;
45
+ T* operator ->() const ;
46
+ T& operator [](difference_type) const ;
47
+
48
+ small_pointer& operator ++();
49
+ small_pointer operator ++(int );
50
+ small_pointer& operator --();
51
+ small_pointer operator --(int );
52
+ small_pointer& operator +=(difference_type);
53
+ small_pointer& operator -=(difference_type);
54
+
55
+ friend small_pointer operator +(small_pointer, difference_type);
56
+ friend small_pointer operator +(difference_type, small_pointer);
57
+ friend small_pointer operator -(small_pointer, difference_type);
58
+ friend difference_type operator -(small_pointer, small_pointer);
59
+
60
+ friend bool operator ==(small_pointer, small_pointer);
61
+ #if TEST_STD_VER < 20
62
+ friend bool operator !=(small_pointer, small_pointer);
63
+ #endif
64
+ friend bool operator <(small_pointer, small_pointer);
65
+ friend bool operator >=(small_pointer, small_pointer);
66
+ friend bool operator >(small_pointer, small_pointer);
67
+ friend bool operator >=(small_pointer, small_pointer);
68
+
69
+ small_pointer pointer_to (T&);
70
+ };
71
+
72
+ template <>
73
+ class small_pointer <const void > {
74
+ std::uint16_t offset;
75
+
76
+ public:
77
+ template <class CT , typename std::enable_if<std::is_convertible<CT*, const void *>::value, int >::type = 0 >
78
+ explicit operator small_pointer<CT>() const ;
79
+ };
80
+
81
+ template <>
82
+ class small_pointer <void *> {
83
+ std::uint16_t offset;
84
+
85
+ public:
86
+ operator small_pointer<const void >() const ;
87
+
88
+ template <class T , typename std::enable_if<std::is_convertible<T*, void *>::value, int >::type = 0 >
89
+ explicit operator small_pointer<T>() const ;
21
90
};
22
91
23
92
template <class T >
@@ -33,8 +102,8 @@ class small_iter_allocator {
33
102
template <class U >
34
103
small_iter_allocator (small_iter_allocator<U>) TEST_NOEXCEPT {}
35
104
36
- T* allocate (std::size_t n);
37
- void deallocate (T* p, std::size_t );
105
+ pointer allocate (std::size_t n);
106
+ void deallocate (pointer p, std::size_t );
38
107
39
108
friend bool operator ==(small_iter_allocator, small_iter_allocator) { return true ; }
40
109
friend bool operator !=(small_iter_allocator, small_iter_allocator) { return false ; }
@@ -53,8 +122,8 @@ class final_small_iter_allocator final {
53
122
template <class U >
54
123
final_small_iter_allocator (final_small_iter_allocator<U>) TEST_NOEXCEPT {}
55
124
56
- T* allocate (std::size_t n);
57
- void deallocate (T* p, std::size_t );
125
+ pointer allocate (std::size_t n);
126
+ void deallocate (pointer p, std::size_t );
58
127
59
128
friend bool operator ==(final_small_iter_allocator, final_small_iter_allocator) { return true ; }
60
129
friend bool operator !=(final_small_iter_allocator, final_small_iter_allocator) { return false ; }
0 commit comments