Function resize

Summary

#include <include/EASTL/string.h>

(1) void resize(size_type n, value_type c)

(2) void resize(size_type n)

Function overload

Synopsis

#include <include/EASTL/string.h>

void resize(size_type n, value_type c)

Description

No description yet.

Source

Lines 1328-1337 in include/EASTL/string.h. Line 597 in include/EASTL/string.h.

template <typename T, typename Allocator>
void basic_string<T, Allocator>::resize(size_type n, value_type c)
{
    const size_type s = internalLayout().GetSize();
    if(n < s)
        erase(internalLayout().BeginPtr() + n, internalLayout().EndPtr());
    else if(n > s)
        append(n - s, c);
}

Synopsis

#include <include/EASTL/string.h>

void resize(size_type n)

Description

No description yet.

Source

Lines 1340-1356 in include/EASTL/string.h. Line 598 in include/EASTL/string.h.

template <typename T, typename Allocator>
void basic_string<T, Allocator>::resize(size_type n)
{
    // C++ basic_string specifies that resize(n) is equivalent to resize(n, value_type()).
    // For built-in types, value_type() is the same as zero (value_type(0)).
    // We can improve the efficiency (especially for long strings) of this
    // string class by resizing without assigning to anything.
    const size_type s = internalLayout().GetSize();
    if(n < s)
        erase(internalLayout().BeginPtr() + n, internalLayout().EndPtr());
    else if(n > s)
    {
        append(n - s, value_type());
    }
}





Add Discussion as Guest

Log in