A RetroSearch Logo

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

Search Query:

Showing content from https://cplusplus.com/basic_string::max_size below:

public member function

<string>

std::basic_string::max_size
size_type max_size() const;
size_type max_size() const noexcept;

Return maximum size

Returns the maximum length the basic_string can reach.

This is the maximum potential length the string can reach due to known system or library implementation limitations, but the object is not guaranteed to be able to reach that length: it can still fail to allocate storage at any point before that length is reached.



Parameters none

Return Value The maximum length the basic_string can reach.

Member type size_type is an unsigned integral type.



Example
1
2
3
4
5
6
7
8
9
10
11
12
13
// comparing size, length, capacity and max_size
#include <iostream>
#include <string>

int main ()
{
  std::string str ("Test string");
  std::cout << "size: " << str.size() << "\n";
  std::cout << "length: " << str.length() << "\n";
  std::cout << "capacity: " << str.capacity() << "\n";
  std::cout << "max_size: " << str.max_size() << "\n";
  return 0;
}

A possible output for this program could be:
size: 11
length: 11
capacity: 15
max_size: 4294967291


Complexity

Unspecified, but generally constant.

Constant.


Iterator validity No changes.

Data races The object is accessed.

Exception safetyNo-throw guarantee: this member function never throws exceptions.

See also
basic_string::capacity
Return size of allocated storage (public member function)
basic_string::size
Return size (public member function)
basic_string::resize
Resize string (public member function)

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