Skip to content

Commit eaade38

Browse files
committed
Add constexpr support for std::list
1 parent e697c99 commit eaade38

File tree

3 files changed

+343
-236
lines changed

3 files changed

+343
-236
lines changed

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
}

0 commit comments

Comments
 (0)