|
14 | 14 | #include <__cstddef/ptrdiff_t.h> |
15 | 15 | #include <__cstddef/size_t.h> |
16 | 16 | #include <__memory/addressof.h> |
17 | | -#include <__memory/allocate_at_least.h> |
18 | 17 | #include <__memory/allocator_traits.h> |
19 | 18 | #include <__new/allocate.h> |
20 | 19 | #include <__new/exceptions.h> |
21 | 20 | #include <__type_traits/is_const.h> |
22 | 21 | #include <__type_traits/is_constant_evaluated.h> |
23 | | -#include <__type_traits/is_same.h> |
24 | | -#include <__type_traits/is_void.h> |
25 | 22 | #include <__type_traits/is_volatile.h> |
26 | 23 | #include <__utility/forward.h> |
27 | 24 |
|
@@ -51,33 +48,8 @@ class allocator<void> { |
51 | 48 | }; |
52 | 49 | #endif // _LIBCPP_STD_VER <= 17 |
53 | 50 |
|
54 | | -// This class provides a non-trivial default constructor to the class that derives from it |
55 | | -// if the condition is satisfied. |
56 | | -// |
57 | | -// The second template parameter exists to allow giving a unique type to __non_trivial_if, |
58 | | -// which makes it possible to avoid breaking the ABI when making this a base class of an |
59 | | -// existing class. Without that, imagine we have classes D1 and D2, both of which used to |
60 | | -// have no base classes, but which now derive from __non_trivial_if. The layout of a class |
61 | | -// that inherits from both D1 and D2 will change because the two __non_trivial_if base |
62 | | -// classes are not allowed to share the same address. |
63 | | -// |
64 | | -// By making those __non_trivial_if base classes unique, we work around this problem and |
65 | | -// it is safe to start deriving from __non_trivial_if in existing classes. |
66 | | -template <bool _Cond, class _Unique> |
67 | | -struct __non_trivial_if {}; |
68 | | - |
69 | | -template <class _Unique> |
70 | | -struct __non_trivial_if<true, _Unique> { |
71 | | - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __non_trivial_if() _NOEXCEPT {} |
72 | | -}; |
73 | | - |
74 | | -// allocator |
75 | | -// |
76 | | -// Note: For ABI compatibility between C++20 and previous standards, we make |
77 | | -// allocator<void> trivial in C++20. |
78 | | - |
79 | 51 | template <class _Tp> |
80 | | -class allocator : private __non_trivial_if<!is_void<_Tp>::value, allocator<_Tp> > { |
| 52 | +class allocator { |
81 | 53 | static_assert(!is_const<_Tp>::value, "std::allocator does not support const types"); |
82 | 54 | static_assert(!is_volatile<_Tp>::value, "std::allocator does not support volatile types"); |
83 | 55 |
|
|
0 commit comments