8
8
9
9
// UNSUPPORTED: libcpp-abi-no-compressed-pair-padding
10
10
11
+ #include < cstddef>
11
12
#include < cstdint>
12
13
#include < deque>
13
14
#include < iterator>
@@ -28,6 +29,9 @@ class small_pointer {
28
29
using pointer = T*;
29
30
using iterator_category = std::random_access_iterator_tag;
30
31
32
+ small_pointer () : offset() {}
33
+ small_pointer (std::nullptr_t ) : offset() {}
34
+
31
35
template <class CT ,
32
36
typename std::enable_if<std::is_same<const T, CT>::value && !std::is_const<T>::value, int >::type = 0 >
33
37
operator small_pointer<CT>() const ;
@@ -41,6 +45,8 @@ class small_pointer {
41
45
int >::type = 0 >
42
46
operator small_pointer<CVoid>() const ;
43
47
48
+ explicit operator bool () const ;
49
+
44
50
T& operator *() const ;
45
51
T* operator ->() const ;
46
52
T& operator [](difference_type) const ;
@@ -52,9 +58,9 @@ class small_pointer {
52
58
small_pointer& operator +=(difference_type);
53
59
small_pointer& operator -=(difference_type);
54
60
55
- friend small_pointer operator +(small_pointer, difference_type) { return small_pointer{} ; }
56
- friend small_pointer operator +(difference_type, small_pointer) { return small_pointer{} ; }
57
- friend small_pointer operator -(small_pointer, difference_type) { return small_pointer{} ; }
61
+ friend small_pointer operator +(small_pointer, difference_type) { return small_pointer () ; }
62
+ friend small_pointer operator +(difference_type, small_pointer) { return small_pointer () ; }
63
+ friend small_pointer operator -(small_pointer, difference_type) { return small_pointer () ; }
58
64
friend difference_type operator -(small_pointer, small_pointer) { return 0 ; }
59
65
60
66
friend bool operator ==(small_pointer, small_pointer) { return true ; }
@@ -66,6 +72,13 @@ class small_pointer {
66
72
friend bool operator >(small_pointer, small_pointer) { return false ; }
67
73
friend bool operator >=(small_pointer, small_pointer) { return true ; }
68
74
75
+ friend bool operator ==(small_pointer, std::nullptr_t ) { return true ; }
76
+ #if TEST_STD_VER < 20
77
+ friend bool operator ==(std::nullptr_t , small_pointer) { return true ; }
78
+ friend bool operator !=(small_pointer, std::nullptr_t ) { return false ; }
79
+ friend bool operator !=(std::nullptr_t , small_pointer) { return false ; }
80
+ #endif
81
+
69
82
small_pointer pointer_to (T&);
70
83
};
71
84
@@ -74,19 +87,43 @@ class small_pointer<const void> {
74
87
std::uint16_t offset;
75
88
76
89
public:
90
+ small_pointer () : offset() {}
91
+ small_pointer (std::nullptr_t ) : offset() {}
92
+
77
93
template <class CT , typename std::enable_if<std::is_convertible<CT*, const void *>::value, int >::type = 0 >
78
94
explicit operator small_pointer<CT>() const ;
95
+
96
+ explicit operator bool () const ;
97
+
98
+ friend bool operator ==(small_pointer, std::nullptr_t ) { return true ; }
99
+ #if TEST_STD_VER < 20
100
+ friend bool operator ==(std::nullptr_t , small_pointer) { return true ; }
101
+ friend bool operator !=(small_pointer, std::nullptr_t ) { return false ; }
102
+ friend bool operator !=(std::nullptr_t , small_pointer) { return false ; }
103
+ #endif
79
104
};
80
105
81
106
template <>
82
107
class small_pointer <void *> {
83
108
std::uint16_t offset;
84
109
85
110
public:
111
+ small_pointer () : offset() {}
112
+ small_pointer (std::nullptr_t ) : offset() {}
113
+
86
114
operator small_pointer<const void >() const ;
87
115
88
116
template <class T , typename std::enable_if<std::is_convertible<T*, void *>::value, int >::type = 0 >
89
117
explicit operator small_pointer<T>() const ;
118
+
119
+ explicit operator bool () const ;
120
+
121
+ friend bool operator ==(small_pointer, std::nullptr_t ) { return true ; }
122
+ #if TEST_STD_VER < 20
123
+ friend bool operator ==(std::nullptr_t , small_pointer) { return true ; }
124
+ friend bool operator !=(small_pointer, std::nullptr_t ) { return false ; }
125
+ friend bool operator !=(std::nullptr_t , small_pointer) { return false ; }
126
+ #endif
90
127
};
91
128
92
129
template <class T >
0 commit comments