Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement P2875R4 Undeprecate polymorphic_allocator::destroy #4532

Merged
merged 2 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions stl/inc/xpolymorphic_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ namespace pmr {

template <class _Uty>
void delete_object(_Uty* const _Ptr) noexcept /* strengthened */ {
_STD _Destroy_in_place(*_Ptr);
_Ptr->~_Uty();
deallocate_object(_Ptr);
}
#endif // _HAS_CXX20
Expand All @@ -296,8 +296,8 @@ namespace pmr {
}

template <class _Uty>
_CXX17_DEPRECATE_POLYMORPHIC_ALLOCATOR_DESTROY void destroy(_Uty* const _Ptr) noexcept /* strengthened */ {
_STD _Destroy_in_place(*_Ptr);
void destroy(_Uty* const _Ptr) noexcept /* strengthened */ {
_Ptr->~_Uty();
StephanTLavavej marked this conversation as resolved.
Show resolved Hide resolved
}

_NODISCARD polymorphic_allocator select_on_container_copy_construction() const noexcept /* strengthened */ {
Expand Down
13 changes: 2 additions & 11 deletions stl/inc/yvals_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
// P2338R4 Freestanding Library: Character Primitives And The C Library
// (including __cpp_lib_freestanding_charconv)
// P2517R1 Conditional noexcept For apply()
// P2875R4 Undeprecate polymorphic_allocator::destroy

// _HAS_CXX17 indirectly controls:
// N4190 Removing auto_ptr, random_shuffle(), And Old <functional> Stuff
Expand Down Expand Up @@ -1386,17 +1387,7 @@ _EMIT_STL_ERROR(STL1004, "C++98 unexpected() is incompatible with C++23 unexpect
#define _CXX20_DEPRECATE_MOVE_ITERATOR_ARROW
#endif // ^^^ warning disabled ^^^

#if _HAS_CXX17 && !defined(_SILENCE_CXX17_POLYMORPHIC_ALLOCATOR_DESTROY_DEPRECATION_WARNING) \
&& !defined(_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS)
#define _CXX17_DEPRECATE_POLYMORPHIC_ALLOCATOR_DESTROY \
[[deprecated("warning STL4032: " \
"std::pmr::polymorphic_allocator::destroy() is deprecated in C++17 by LWG-3036. " \
"Prefer std::destroy_at() or std::allocator_traits<polymorphic_allocator>::destroy(). " \
"You can define _SILENCE_CXX17_POLYMORPHIC_ALLOCATOR_DESTROY_DEPRECATION_WARNING " \
"or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to suppress this warning.")]]
#else // ^^^ warning enabled / warning disabled vvv
#define _CXX17_DEPRECATE_POLYMORPHIC_ALLOCATOR_DESTROY
#endif // ^^^ warning disabled ^^^
// STL4032 was "std::pmr::polymorphic_allocator::destroy() is deprecated in C++17 by LWG-3036." (reverted by P2875R4)

#if _HAS_CXX20 && !defined(_SILENCE_CXX20_IS_ALWAYS_EQUAL_DEPRECATION_WARNING) \
&& !defined(_SILENCE_ALL_CXX20_DEPRECATION_WARNINGS)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#define _SILENCE_CXX17_POLYMORPHIC_ALLOCATOR_DESTROY_DEPRECATION_WARNING
#define _SILENCE_CXX23_ALIGNED_UNION_DEPRECATION_WARNING

#include <algorithm>
Expand Down