Function swap

Synopsis

#include <include/EASTL/any.h>

void swap(any &other) EA_NOEXCEPT

Description

No description yet.

Source

Lines 487-518 in include/EASTL/any.h.

void swap(any& other) EA_NOEXCEPT 
{
    if(this == &other)
        return;
    if(m_handler && other.m_handler)
    {
        any tmp;
        tmp.m_handler = other.m_handler;
        other.m_handler(storage_operation::MOVE, &other, &tmp);
        other.m_handler = m_handler;
        m_handler(storage_operation::MOVE, this, &other);
        m_handler = tmp.m_handler;
        tmp.m_handler(storage_operation::MOVE, &tmp, this);
    }
    else if (m_handler == nullptr && other.m_handler)
    {
        eastl::swap(m_handler, other.m_handler);
        m_handler(storage_operation::MOVE, &other, this);
    }
    else if(m_handler && other.m_handler == nullptr)
    {
        eastl::swap(m_handler, other.m_handler);
        other.m_handler(storage_operation::MOVE, this, &other);
    }
    //else if (m_handler == nullptr && other.m_handler == nullptr)
    //{
    //     // nothing to swap 
    //}
}





Add Discussion as Guest

Log in