Skip to content

Commit

Permalink
Implement P2875R4 Undeprecate polymorphic_allocator::destroy (#4532)
Browse files Browse the repository at this point in the history
Co-authored-by: Stephan T. Lavavej <[email protected]>
  • Loading branch information
frederick-vs-ja and StephanTLavavej authored Mar 28, 2024
1 parent d8f6dc5 commit fbdcee4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 15 deletions.
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();
}

_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 @@ -1387,17 +1388,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

0 comments on commit fbdcee4

Please sign in to comment.