88
99// UNSUPPORTED: libcpp-abi-no-compressed-pair-padding
1010
11+ #include < cstddef>
1112#include < cstdint>
1213#include < deque>
1314#include < iterator>
@@ -28,6 +29,9 @@ class small_pointer {
2829 using pointer = T*;
2930 using iterator_category = std::random_access_iterator_tag;
3031
32+ small_pointer () : offset() {}
33+ small_pointer (std::nullptr_t ) : offset() {}
34+
3135 template <class CT ,
3236 typename std::enable_if<std::is_same<const T, CT>::value && !std::is_const<T>::value, int >::type = 0 >
3337 operator small_pointer<CT>() const ;
@@ -41,6 +45,8 @@ class small_pointer {
4145 int >::type = 0 >
4246 operator small_pointer<CVoid>() const ;
4347
48+ explicit operator bool () const ;
49+
4450 T& operator *() const ;
4551 T* operator ->() const ;
4652 T& operator [](difference_type) const ;
@@ -52,9 +58,9 @@ class small_pointer {
5258 small_pointer& operator +=(difference_type);
5359 small_pointer& operator -=(difference_type);
5460
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 () ; }
5864 friend difference_type operator -(small_pointer, small_pointer) { return 0 ; }
5965
6066 friend bool operator ==(small_pointer, small_pointer) { return true ; }
@@ -66,6 +72,13 @@ class small_pointer {
6672 friend bool operator >(small_pointer, small_pointer) { return false ; }
6773 friend bool operator >=(small_pointer, small_pointer) { return true ; }
6874
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+
6982 small_pointer pointer_to (T&);
7083};
7184
@@ -74,19 +87,43 @@ class small_pointer<const void> {
7487 std::uint16_t offset;
7588
7689public:
90+ small_pointer () : offset() {}
91+ small_pointer (std::nullptr_t ) : offset() {}
92+
7793 template <class CT , typename std::enable_if<std::is_convertible<CT*, const void *>::value, int >::type = 0 >
7894 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
79104};
80105
81106template <>
82107class small_pointer <void *> {
83108 std::uint16_t offset;
84109
85110public:
111+ small_pointer () : offset() {}
112+ small_pointer (std::nullptr_t ) : offset() {}
113+
86114 operator small_pointer<const void >() const ;
87115
88116 template <class T , typename std::enable_if<std::is_convertible<T*, void *>::value, int >::type = 0 >
89117 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
90127};
91128
92129template <class T >
0 commit comments