A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://timsong-cpp.github.io/cppwp/n4659/string.capacity below:

[string.capacity]

24 Strings library [strings] 24.3 String classes [string.classes] 24.3.2 Class template basic_­string [basic.string] 24.3.2.4 basic_­string capacity [string.capacity]

size_type size() const noexcept;

Returns: A count of the number of char-like objects currently in the string.

Complexity: Constant time.

size_type length() const noexcept;

size_type max_size() const noexcept;

Returns: The largest possible number of char-like objects that can be stored in a basic_­string.

Complexity: Constant time.

void resize(size_type n, charT c);

Throws: length_­error if n > max_­size().

Effects: Alters the length of the string designated by *this as follows:

void resize(size_type n);

Effects: As if by resize(n, charT()).

size_type capacity() const noexcept;

Returns: The size of the allocated storage in the string.

void reserve(size_type res_arg=0);

The member function reserve() is a directive that informs a basic_­string object of a planned change in size, so that it can manage the storage allocation accordingly.

Effects: After reserve(), capacity() is greater or equal to the argument of reserve. [Note: Calling reserve() with a res_­arg argument less than capacity() is in effect a non-binding shrink request. A call with res_­arg <= size() is in effect a non-binding shrink-to-fit request. end note]

Throws: length_­error if res_­arg > max_­size().227

void shrink_to_fit();

Effects: shrink_­to_­fit is a non-binding request to reduce capacity() to size(). [Note: The request is non-binding to allow latitude for implementation-specific optimizations. end note] It does not increase capacity(), but may reduce capacity() by causing reallocation.

Complexity: Linear in the size of the sequence.

Remarks: Reallocation invalidates all the references, pointers, and iterators referring to the elements in the sequence as well as the past-the-end iterator. If no reallocation happens, they remain valid.

void clear() noexcept;

Effects: Behaves as if the function calls:

erase(begin(), end());

bool empty() const noexcept;


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4