Function erase

Summary

#include <include/EASTL/string.h>

(1) this_type & erase(size_type position=0, size_type n=npos)

(2) iterator erase(const_iterator p)

(3) iterator erase(const_iterator pBegin, const_iterator pEnd)

(4) reverse_iterator erase(reverse_iterator position)

(5) reverse_iterator erase(reverse_iterator first, reverse_iterator last)

Function overload

Synopsis

#include <include/EASTL/string.h>

this_type & erase(size_type position=0, size_type n=npos)

Description

Erase operations.

Source

Lines 2322-2339 in include/EASTL/string.h. Line 658 in include/EASTL/string.h.

template <typename T, typename Allocator>
inline basic_string<T, Allocator>& basic_string<T, Allocator>::erase(size_type position, size_type n)
{
    #if EASTL_STRING_OPT_RANGE_ERRORS
        if(EASTL_UNLIKELY(position > internalLayout().GetSize()))
            ThrowRangeException();
    #endif
    #if EASTL_ASSERT_ENABLED
        if(EASTL_UNLIKELY(position > internalLayout().GetSize()))
            EASTL_FAIL_MSG("basic_string::erase -- invalid position");
    #endif
    erase(internalLayout().BeginPtr() + position,
          internalLayout().BeginPtr() + position + eastl::min_alt(n, internalLayout().GetSize() - position));
    return *this;
}

Synopsis

#include <include/EASTL/string.h>

iterator erase(const_iterator p)

Description

No description yet.

Source

Lines 2342-2354 in include/EASTL/string.h. Line 659 in include/EASTL/string.h.

template <typename T, typename Allocator>
inline typename basic_string<T, Allocator>::iterator
basic_string<T, Allocator>::erase(const_iterator p)
{
    #if EASTL_ASSERT_ENABLED
        if(EASTL_UNLIKELY((p < internalLayout().BeginPtr()) || (p >= internalLayout().EndPtr())))
            EASTL_FAIL_MSG("basic_string::erase -- invalid position");
    #endif
    memmove(const_cast<value_type*>(p), p + 1, (size_t)(internalLayout().EndPtr() - p) * sizeof(value_type));
    internalLayout().SetSize(internalLayout().GetSize() - 1);
    return const_cast<value_type*>(p);
}

Synopsis

#include <include/EASTL/string.h>

iterator erase(const_iterator pBegin, const_iterator pEnd)

Description

No description yet.

Source

Lines 2357-2374 in include/EASTL/string.h. Line 660 in include/EASTL/string.h.

template <typename T, typename Allocator>
typename basic_string<T, Allocator>::iterator
basic_string<T, Allocator>::erase(const_iterator pBegin, const_iterator pEnd)
{
    #if EASTL_ASSERT_ENABLED
        if (EASTL_UNLIKELY((pBegin < internalLayout().BeginPtr()) || (pBegin > internalLayout().EndPtr()) ||
                           (pEnd < internalLayout().BeginPtr()) || (pEnd > internalLayout().EndPtr()) || (pEnd < pBegin)))
            EASTL_FAIL_MSG("basic_string::erase -- invalid position");
    #endif
    if(pBegin != pEnd)
    {
        memmove(const_cast<value_type*>(pBegin), pEnd, (size_t)((internalLayout().EndPtr() - pEnd) + 1) * sizeof(value_type));
        const size_type n = (size_type)(pEnd - pBegin);
        internalLayout().SetSize(internalLayout().GetSize() - n);
    }
    return const_cast<value_type*>(pBegin);
}

Synopsis

#include <include/EASTL/string.h>

reverse_iterator erase(reverse_iterator position)

Description

No description yet.

Source

Lines 2377-2382 in include/EASTL/string.h. Line 661 in include/EASTL/string.h.

template <typename T, typename Allocator>
inline typename basic_string<T, Allocator>::reverse_iterator
basic_string<T, Allocator>::erase(reverse_iterator position)
{
    return reverse_iterator(erase((++position).base()));
}

Synopsis

#include <include/EASTL/string.h>

reverse_iterator erase(reverse_iterator first, reverse_iterator last)

Description

No description yet.

Source

Lines 2385-2390 in include/EASTL/string.h. Line 662 in include/EASTL/string.h.

template <typename T, typename Allocator>
typename basic_string<T, Allocator>::reverse_iterator
basic_string<T, Allocator>::erase(reverse_iterator first, reverse_iterator last)
{
    return reverse_iterator(erase((++last).base(), (++first).base()));
}





Add Discussion as Guest

Log in