Skip to content

File tree

13 files changed

+56
-48
lines changed

13 files changed

+56
-48
lines changed

libcxx/docs/FeatureTestMacroTable.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ Status
304304
---------------------------------------------------------------------
305305
``__cpp_lib_adaptor_iterator_pair_constructor`` ``202106L``
306306
--------------------------------------------------- -----------------
307-
``__cpp_lib_allocate_at_least`` ``202106L``
307+
``__cpp_lib_allocate_at_least`` ``202302L``
308308
--------------------------------------------------- -----------------
309309
``__cpp_lib_associative_heterogeneous_erasure`` *unimplemented*
310310
--------------------------------------------------- -----------------

libcxx/docs/ReleaseNotes/19.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ What's New in Libc++ 19.0.0?
3737

3838
Implemented Papers
3939
------------------
40+
4041
- P2637R3 - Member ``visit``
42+
- P2652R2 - Disallow User Specialization of ``allocator_traits``
4143

4244

4345
Improvements and New Features

libcxx/docs/Status/Cxx23Papers.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
"`P2679R2 <https://wg21.link/P2679R2>`__","LWG", "Fixing ``std::start_lifetime_as`` for arrays","February 2023","","",""
116116
"`P2674R1 <https://wg21.link/P2674R1>`__","LWG", "A trait for implicit lifetime types","February 2023","","",""
117117
"`P2655R3 <https://wg21.link/P2655R3>`__","LWG", "``common_reference_t`` of ``reference_wrapper`` Should Be a Reference Type","February 2023","","",""
118-
"`P2652R2 <https://wg21.link/P2652R2>`__","LWG", "Disallow User Specialization of ``allocator_traits``","February 2023","","",""
118+
"`P2652R2 <https://wg21.link/P2652R2>`__","LWG", "Disallow User Specialization of ``allocator_traits``","February 2023","|Complete|","19.0",""
119119
"`P2787R1 <https://wg21.link/P2787R1>`__","LWG", "``pmr::generator`` - Promise Types are not Values","February 2023","","",""
120120
"`P2614R2 <https://wg21.link/P2614R2>`__","LWG", "Deprecate ``numeric_limits::has_denorm``","February 2023","|Complete|","18.0",""
121121
"`P2588R3 <https://wg21.link/P2588R3>`__","LWG", "``barrier``’s phase completion guarantees","February 2023","","",""

libcxx/docs/Status/Cxx2cIssues.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"`2994 <https://wg21.link/LWG2994>`__","Needless UB for ``basic_string`` and ``basic_string_view``","Varna June 2023","|Complete|","5.0",""
33
"`3884 <https://wg21.link/LWG3884>`__","``flat_foo`` is missing allocator-extended copy/move constructors","Varna June 2023","","","|flat_containers|"
44
"`3885 <https://wg21.link/LWG3885>`__","``op`` should be in [zombie.names]","Varna June 2023","|Nothing To Do|","",""
5-
"`3887 <https://wg21.link/LWG3887>`__","Version macro for ``allocate_at_least``","Varna June 2023","","",""
5+
"`3887 <https://wg21.link/LWG3887>`__","Version macro for ``allocate_at_least``","Varna June 2023","|Complete|","19.0",""
66
"`3893 <https://wg21.link/LWG3893>`__","LWG 3661 broke ``atomic<shared_ptr<T>> a; a = nullptr;``","Varna June 2023","","",""
77
"`3894 <https://wg21.link/LWG3894>`__","``generator::promise_type::yield_value(ranges::elements_of<Rng, Alloc>)`` should not be ``noexcept``","Varna June 2023","","",""
88
"`3903 <https://wg21.link/LWG3903>`__","span destructor is redundantly noexcept","Varna June 2023","|Complete|","7.0",""

libcxx/include/__memory/allocate_at_least.h

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,14 @@
2020
_LIBCPP_BEGIN_NAMESPACE_STD
2121

2222
#if _LIBCPP_STD_VER >= 23
23-
template <class _Pointer>
24-
struct allocation_result {
25-
_Pointer ptr;
26-
size_t count;
27-
};
28-
_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(allocation_result);
29-
30-
template <class _Alloc>
31-
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr allocation_result<typename allocator_traits<_Alloc>::pointer>
32-
allocate_at_least(_Alloc& __alloc, size_t __n) {
33-
if constexpr (requires { __alloc.allocate_at_least(__n); }) {
34-
return __alloc.allocate_at_least(__n);
35-
} else {
36-
return {__alloc.allocate(__n), __n};
37-
}
38-
}
3923

4024
template <class _Alloc>
4125
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto __allocate_at_least(_Alloc& __alloc, size_t __n) {
42-
return std::allocate_at_least(__alloc, __n);
26+
return std::allocator_traits<_Alloc>::allocate_at_least(__alloc, __n);
4327
}
28+
4429
#else
30+
4531
template <class _Pointer>
4632
struct __allocation_result {
4733
_Pointer ptr;

libcxx/include/__memory/allocator_traits.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <__type_traits/void_t.h>
2323
#include <__utility/declval.h>
2424
#include <__utility/forward.h>
25+
#include <cstddef>
2526
#include <limits>
2627

2728
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -231,6 +232,17 @@ struct __has_select_on_container_copy_construction<
231232

232233
_LIBCPP_SUPPRESS_DEPRECATED_POP
233234

235+
#if _LIBCPP_STD_VER >= 23
236+
237+
template <class _Pointer, class _SizeType = size_t>
238+
struct allocation_result {
239+
_Pointer ptr;
240+
_SizeType count;
241+
};
242+
_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(allocation_result);
243+
244+
#endif // _LIBCPP_STD_VER
245+
234246
template <class _Alloc>
235247
struct _LIBCPP_TEMPLATE_VIS allocator_traits {
236248
using allocator_type = _Alloc;
@@ -284,6 +296,18 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits {
284296
return __a.allocate(__n);
285297
}
286298

299+
#if _LIBCPP_STD_VER >= 23
300+
template <class _Ap = _Alloc>
301+
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr allocation_result<pointer, size_type>
302+
allocate_at_least(_Ap& __alloc, size_type __n) {
303+
if constexpr (requires { __alloc.allocate_at_least(__n); }) {
304+
return __alloc.allocate_at_least(__n);
305+
} else {
306+
return {__alloc.allocate(__n), __n};
307+
}
308+
}
309+
#endif
310+
287311
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void
288312
deallocate(allocator_type& __a, pointer __p, size_type __n) _NOEXCEPT {
289313
__a.deallocate(__p, __n);

libcxx/include/memory

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ struct allocator_traits
8888
static pointer allocate(allocator_type& a, size_type n); // constexpr and [[nodiscard]] in C++20
8989
static pointer allocate(allocator_type& a, size_type n, const_void_pointer hint); // constexpr and [[nodiscard]] in C++20
9090
91+
[[nodiscard]] static constexpr allocation_result<pointer, size_type>
92+
allocate_at_least(Alloc& a, size_type n); // Since C++23
93+
9194
static void deallocate(allocator_type& a, pointer p, size_type n) noexcept; // constexpr in C++20
9295
9396
template <class T, class... Args>
@@ -100,15 +103,11 @@ struct allocator_traits
100103
static allocator_type select_on_container_copy_construction(const allocator_type& a); // constexpr in C++20
101104
};
102105
103-
template<class Pointer>
106+
template<class Pointer, class SizeType = size_t>
104107
struct allocation_result {
105108
Pointer ptr;
106-
size_t count;
107-
}; // since C++23
108-
109-
template<class Allocator>
110-
[[nodiscard]] constexpr allocation_result<typename allocator_traits<Allocator>::pointer>
111-
allocate_at_least(Allocator& a, size_t n); // since C++23
109+
SizeType count;
110+
}; // Since C++23
112111
113112
template <>
114113
class allocator<void> // removed in C++20

libcxx/include/version

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
Macro name Value Headers
1717
__cpp_lib_adaptor_iterator_pair_constructor 202106L <queue> <stack>
1818
__cpp_lib_addressof_constexpr 201603L <memory>
19-
__cpp_lib_allocate_at_least 202106L <memory>
19+
__cpp_lib_allocate_at_least 202302L <memory>
2020
__cpp_lib_allocator_traits_is_always_equal 201411L <deque> <forward_list> <list>
2121
<map> <memory> <scoped_allocator>
2222
<set> <string> <unordered_map>
@@ -433,7 +433,7 @@ __cpp_lib_within_lifetime 202306L <type_traits>
433433

434434
#if _LIBCPP_STD_VER >= 23
435435
# define __cpp_lib_adaptor_iterator_pair_constructor 202106L
436-
# define __cpp_lib_allocate_at_least 202106L
436+
# define __cpp_lib_allocate_at_least 202302L
437437
// # define __cpp_lib_associative_heterogeneous_erasure 202110L
438438
// # define __cpp_lib_bind_back 202202L
439439
# define __cpp_lib_byteswap 202110L

libcxx/modules/std/memory.inc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ export namespace std {
4343

4444
#if _LIBCPP_STD_VER >= 23
4545
using std::allocation_result;
46-
47-
using std::allocate_at_least;
4846
#endif
4947

5048
// [default.allocator], the default allocator

libcxx/test/std/language.support/support.limits/support.limits.general/memory.version.compile.pass.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
/* Constant Value
1919
__cpp_lib_addressof_constexpr 201603L [C++17]
20-
__cpp_lib_allocate_at_least 202106L [C++23]
20+
__cpp_lib_allocate_at_least 202302L [C++23]
2121
__cpp_lib_allocator_traits_is_always_equal 201411L [C++17]
2222
__cpp_lib_assume_aligned 201811L [C++20]
2323
__cpp_lib_atomic_value_initialization 201911L [C++20]
@@ -432,8 +432,8 @@
432432
# ifndef __cpp_lib_allocate_at_least
433433
# error "__cpp_lib_allocate_at_least should be defined in c++23"
434434
# endif
435-
# if __cpp_lib_allocate_at_least != 202106L
436-
# error "__cpp_lib_allocate_at_least should have the value 202106L in c++23"
435+
# if __cpp_lib_allocate_at_least != 202302L
436+
# error "__cpp_lib_allocate_at_least should have the value 202302L in c++23"
437437
# endif
438438

439439
# ifndef __cpp_lib_allocator_traits_is_always_equal
@@ -569,8 +569,8 @@
569569
# ifndef __cpp_lib_allocate_at_least
570570
# error "__cpp_lib_allocate_at_least should be defined in c++26"
571571
# endif
572-
# if __cpp_lib_allocate_at_least != 202106L
573-
# error "__cpp_lib_allocate_at_least should have the value 202106L in c++26"
572+
# if __cpp_lib_allocate_at_least != 202302L
573+
# error "__cpp_lib_allocate_at_least should have the value 202302L in c++26"
574574
# endif
575575

576576
# ifndef __cpp_lib_allocator_traits_is_always_equal

0 commit comments

Comments
 (0)