Skip to content

Commit 56fcc31

Browse files
Address review comments
1 parent a976380 commit 56fcc31

File tree

3 files changed

+6
-109
lines changed

3 files changed

+6
-109
lines changed

libcxx/docs/ReleaseNotes/22.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ ABI Affecting Changes
6161
- The ``const_iterator`` member type of ``std::deque`` is now corrected to hold a (possibly fancy) pointer to the
6262
(possibly fancy) pointer allocated in the internal map. E.g. when the allocators use fancy pointers, the internal map
6363
stores ``fancy_ptr<T>`` objects, and the previous strategy accessed these objects via ``const fancy_ptr<const T>``
64-
lvalues, which usually caused core language undefined behavior. Now ``const_iterator`` stores
64+
lvalues, caused undefined behavior. Now ``const_iterator`` stores
6565
``fancy_ptr<const fancy_ptr<T>>`` instead of ``fancy_ptr<const fancy_ptr<const T>>``, and ABI break can happen when
6666
such two types have incompatible layouts. This is necessary for reducing undefined behavior and ``constexpr`` support
6767
for ``deque`` in C++26, so we do not provide any way to opt-out of that behavior.

libcxx/include/deque

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ public:
535535
using const_reference = const value_type&;
536536

537537
using iterator = __deque_iterator<value_type, pointer, reference, __map_pointer, difference_type>;
538-
using const_iterator = // Use of __map_const_pointer is merely kept for API stability.
538+
using const_iterator = // Use of __map_const_pointer is merely kept for stability of const_iterator's true name.
539539
__deque_iterator<value_type, const_pointer, const_reference, __map_const_pointer, difference_type>;
540540
using reverse_iterator = std::reverse_iterator<iterator>;
541541
using const_reverse_iterator = std::reverse_iterator<const_iterator>;

libcxx/test/libcxx/containers/sequences/deque/abi.compile.pass.cpp

Lines changed: 4 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,8 @@
88

99
// UNSUPPORTED: libcpp-abi-no-compressed-pair-padding
1010

11-
#include <cstddef>
1211
#include <cstdint>
1312
#include <deque>
14-
#include <iterator>
15-
#include <type_traits>
1613

1714
#include "min_allocator.h"
1815
#include "test_allocator.h"
@@ -23,107 +20,7 @@ class small_pointer {
2320
std::uint16_t offset;
2421

2522
public:
26-
using value_type = typename std::remove_cv<T>::type;
27-
using difference_type = std::int16_t;
28-
using reference = T&;
29-
using pointer = T*;
30-
using iterator_category = std::random_access_iterator_tag;
31-
32-
small_pointer() : offset() {}
33-
small_pointer(std::nullptr_t) : offset() {}
34-
35-
template <class CT,
36-
typename std::enable_if<std::is_same<const T, CT>::value && !std::is_const<T>::value, int>::type = 0>
37-
operator small_pointer<CT>() const;
38-
template <
39-
class Void,
40-
typename std::enable_if<std::is_same<Void, void>::value && std::is_convertible<T*, void*>::value, int>::type = 0>
41-
operator small_pointer<Void>() const;
42-
template <
43-
class CVoid,
44-
typename std::enable_if<std::is_same<CVoid, const void>::value && std::is_convertible<T*, const void*>::value,
45-
int>::type = 0>
46-
operator small_pointer<CVoid>() const;
47-
48-
explicit operator bool() const;
49-
5023
T& operator*() const;
51-
T* operator->() const;
52-
T& operator[](difference_type) const;
53-
54-
small_pointer& operator++();
55-
small_pointer operator++(int);
56-
small_pointer& operator--();
57-
small_pointer operator--(int);
58-
small_pointer& operator+=(difference_type);
59-
small_pointer& operator-=(difference_type);
60-
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(); }
64-
friend difference_type operator-(small_pointer, small_pointer) { return 0; }
65-
66-
friend bool operator==(small_pointer, small_pointer) { return true; }
67-
#if TEST_STD_VER < 20
68-
friend bool operator!=(small_pointer, small_pointer) { return false; }
69-
#endif
70-
friend bool operator<(small_pointer, small_pointer) { return false; }
71-
friend bool operator<=(small_pointer, small_pointer) { return true; }
72-
friend bool operator>(small_pointer, small_pointer) { return false; }
73-
friend bool operator>=(small_pointer, small_pointer) { return true; }
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-
82-
small_pointer pointer_to(T&);
83-
};
84-
85-
template <>
86-
class small_pointer<const void> {
87-
std::uint16_t offset;
88-
89-
public:
90-
small_pointer() : offset() {}
91-
small_pointer(std::nullptr_t) : offset() {}
92-
93-
template <class CT, typename std::enable_if<std::is_convertible<CT*, const void*>::value, int>::type = 0>
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
104-
};
105-
106-
template <>
107-
class small_pointer<void*> {
108-
std::uint16_t offset;
109-
110-
public:
111-
small_pointer() : offset() {}
112-
small_pointer(std::nullptr_t) : offset() {}
113-
114-
operator small_pointer<const void>() const;
115-
116-
template <class T, typename std::enable_if<std::is_convertible<T*, void*>::value, int>::type = 0>
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
12724
};
12825

12926
template <class T>
@@ -139,8 +36,8 @@ class small_iter_allocator {
13936
template <class U>
14037
small_iter_allocator(small_iter_allocator<U>) TEST_NOEXCEPT {}
14138

142-
pointer allocate(std::size_t n);
143-
void deallocate(pointer p, std::size_t);
39+
T* allocate(std::size_t n);
40+
void deallocate(T* p, std::size_t);
14441

14542
friend bool operator==(small_iter_allocator, small_iter_allocator) { return true; }
14643
friend bool operator!=(small_iter_allocator, small_iter_allocator) { return false; }
@@ -159,8 +56,8 @@ class final_small_iter_allocator final {
15956
template <class U>
16057
final_small_iter_allocator(final_small_iter_allocator<U>) TEST_NOEXCEPT {}
16158

162-
pointer allocate(std::size_t n);
163-
void deallocate(pointer p, std::size_t);
59+
T* allocate(std::size_t n);
60+
void deallocate(T* p, std::size_t);
16461

16562
friend bool operator==(final_small_iter_allocator, final_small_iter_allocator) { return true; }
16663
friend bool operator!=(final_small_iter_allocator, final_small_iter_allocator) { return false; }

0 commit comments

Comments
 (0)