[libcxx-commits] [libcxx] [libc++] Use __alloc_traits whenever it is available for consistency (PR #126595)
Peng Liu via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Feb 11 07:44:27 PST 2025
================
@@ -719,7 +719,7 @@ public:
_LIBCPP_HIDE_FROM_ABI forward_list& operator=(forward_list&& __x) noexcept(
(__node_traits::propagate_on_container_move_assignment::value &&
is_nothrow_move_assignable<allocator_type>::value) ||
- allocator_traits<allocator_type>::is_always_equal::value);
+ __node_traits::is_always_equal::value);
----------------
winner245 wrote:
Thank you for your careful thought. I agree with you that for containers with a rebound allocator, if `XX::is_always_equal::value != YY::is_always_equal::value` (where `XX` and `YY` represents the original and rebound allocator traits), we would have trouble. But it seems that libc++ implicitly assumes `XX::is_always_equal::value == YY::is_always_equal::value` (perhaps even `XX::pocma::value == YY::pocma::value`), which allows us to use `__node_traits` instead of `allocator_traits<allocator_type>`. I've also checked the implementations in libstdc++ and MSVC-STL. It seems that they both have this assumption implicitly.
https://github.com/llvm/llvm-project/pull/126595
More information about the libcxx-commits
mailing list