Skip to content

Commit 0962cd8

Browse files
author
Vladimir 'virtul' Ivannikov
committed
fix swap of e.g .eastl::list<unique_ptr[]> with stateless/default allocator
...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
1 parent 7fadbf0 commit 0962cd8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

include/EASTL/list.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1571,7 +1571,9 @@ namespace eastl
15711571
template <typename T, typename Allocator>
15721572
inline void list<T, Allocator>::swap(this_type& x)
15731573
{
1574-
if(internalAllocator() == x.internalAllocator()) // If allocators are equivalent...
1574+
if constexpr (is_empty_v<allocator_type>)
1575+
DoSwap(x);
1576+
else if (internalAllocator() == x.internalAllocator()) // If allocators are equivalent...
15751577
DoSwap(x);
15761578
else // else swap the contents.
15771579
{

0 commit comments

Comments
 (0)