Function swap

Synopsis

#include <include/EASTL/string.h>

void swap(this_type &x)

Description

No description yet.

Source

Lines 2609-2623 in include/EASTL/string.h. Line 552 in include/EASTL/string.h.

template <typename T, typename Allocator>
void basic_string<T, Allocator>::swap(this_type& x)
{
    if(get_allocator() == x.get_allocator() || (internalLayout().IsSSO() && x.internalLayout().IsSSO())) // If allocators are equivalent...
    {
        // We leave mAllocator as-is.
        eastl::swap(internalLayout(), x.internalLayout());
    }
    else // else swap the contents.
    {
        const this_type temp(*this); // Can't call eastl::swap because that would
        *this = x;                   // itself call this member swap function.
        x     = temp;
    }
}





Add Discussion as Guest

Log in