Skip to content

Commit

Permalink
fix swap of e.g .eastl::list<unique_ptr[]> with stateless/default all…
Browse files Browse the repository at this point in the history
…ocator

...or any other type that has deleted copy ctor.
Assume that if `allocator_type` is empty (*) then it's automatically
equal to passed instance and we can erase compile-time const assignment
branch, which is not compiles when T's copy ctor is deleted (e.g. unique_ptr)

(*) implicitly implied EASTL_NAME_ENABLED being off, since it's makes
allocator_type statefull
  • Loading branch information
Vladimir 'virtul' Ivannikov committed Feb 7, 2025
1 parent 7fadbf0 commit 0962cd8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion include/EASTL/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -1571,7 +1571,9 @@ namespace eastl
template <typename T, typename Allocator>
inline void list<T, Allocator>::swap(this_type& x)
{
if(internalAllocator() == x.internalAllocator()) // If allocators are equivalent...
if constexpr (is_empty_v<allocator_type>)
DoSwap(x);
else if (internalAllocator() == x.internalAllocator()) // If allocators are equivalent...
DoSwap(x);
else // else swap the contents.
{
Expand Down

0 comments on commit 0962cd8

Please sign in to comment.