Skip to content

Commit b6b770f

Browse files
committed
Make list constexpr as part of P3372R3
1 parent d90423e commit b6b770f

File tree

73 files changed

+1656
-880
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+1656
-880
lines changed

libcxx/docs/FeatureTestMacroTable.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,8 @@ Status
416416
---------------------------------------------------------- -----------------
417417
``__cpp_lib_bitset`` ``202306L``
418418
---------------------------------------------------------- -----------------
419+
``__cpp_lib_constexpr_list`` ``202502L``
420+
---------------------------------------------------------- -----------------
419421
``__cpp_lib_constexpr_new`` ``202406L``
420422
---------------------------------------------------------- -----------------
421423
``__cpp_lib_constrained_equality`` *unimplemented*

libcxx/include/__memory/allocation_guard.h

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,26 @@ struct __allocation_guard {
4949
using _Size _LIBCPP_NODEBUG = typename allocator_traits<_Alloc>::size_type;
5050

5151
template <class _AllocT> // we perform the allocator conversion inside the constructor
52-
_LIBCPP_HIDE_FROM_ABI explicit __allocation_guard(_AllocT __alloc, _Size __n)
52+
_LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit __allocation_guard(_AllocT __alloc, _Size __n)
5353
: __alloc_(std::move(__alloc)),
5454
__n_(__n),
5555
__ptr_(allocator_traits<_Alloc>::allocate(__alloc_, __n_)) // initialization order is important
5656
{}
5757

58-
_LIBCPP_HIDE_FROM_ABI ~__allocation_guard() _NOEXCEPT { __destroy(); }
58+
_LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI ~__allocation_guard() _NOEXCEPT { __destroy(); }
5959

60-
_LIBCPP_HIDE_FROM_ABI __allocation_guard(const __allocation_guard&) = delete;
61-
_LIBCPP_HIDE_FROM_ABI __allocation_guard(__allocation_guard&& __other) _NOEXCEPT
60+
_LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __allocation_guard(const __allocation_guard&) = delete;
61+
_LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __allocation_guard(__allocation_guard&& __other) _NOEXCEPT
6262
: __alloc_(std::move(__other.__alloc_)),
6363
__n_(__other.__n_),
6464
__ptr_(__other.__ptr_) {
6565
__other.__ptr_ = nullptr;
6666
}
6767

68-
_LIBCPP_HIDE_FROM_ABI __allocation_guard& operator=(const __allocation_guard& __other) = delete;
69-
_LIBCPP_HIDE_FROM_ABI __allocation_guard& operator=(__allocation_guard&& __other) _NOEXCEPT {
68+
_LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __allocation_guard&
69+
operator=(const __allocation_guard& __other) = delete;
70+
_LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __allocation_guard&
71+
operator=(__allocation_guard&& __other) _NOEXCEPT {
7072
if (std::addressof(__other) != this) {
7173
__destroy();
7274

@@ -79,17 +81,17 @@ struct __allocation_guard {
7981
return *this;
8082
}
8183

82-
_LIBCPP_HIDE_FROM_ABI _Pointer
84+
_LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI _Pointer
8385
__release_ptr() _NOEXCEPT { // not called __release() because it's a keyword in objective-c++
8486
_Pointer __tmp = __ptr_;
8587
__ptr_ = nullptr;
8688
return __tmp;
8789
}
8890

89-
_LIBCPP_HIDE_FROM_ABI _Pointer __get() const _NOEXCEPT { return __ptr_; }
91+
_LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI _Pointer __get() const _NOEXCEPT { return __ptr_; }
9092

9193
private:
92-
_LIBCPP_HIDE_FROM_ABI void __destroy() _NOEXCEPT {
94+
_LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __destroy() _NOEXCEPT {
9395
if (__ptr_ != nullptr) {
9496
allocator_traits<_Alloc>::deallocate(__alloc_, __ptr_, __n_);
9597
}

libcxx/include/__memory/pointer_traits.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,14 @@ concept __resettable_smart_pointer_with_args = requires(_Smart __s, _Pointer __p
302302

303303
#endif
304304

305+
template <class _PtrTo, class _PtrFrom>
306+
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI _PtrTo __static_fancy_pointer_cast(const _PtrFrom& __p) {
307+
using __ptr_traits = pointer_traits<_PtrTo>;
308+
using __element_type = typename __ptr_traits::element_type;
309+
return __p ? __ptr_traits::pointer_to(*static_cast<__element_type*>(std::addressof(*__p)))
310+
: static_cast<_PtrTo>(nullptr);
311+
}
312+
305313
_LIBCPP_END_NAMESPACE_STD
306314

307315
_LIBCPP_POP_MACROS

0 commit comments

Comments
 (0)