public member function
<string>
std::basic_string::size
size_type size() const noexcept;
Return size
This is the number of actual characters that conform the contents of the basic_string, which is not necessarily equal to its storage capacity.
Both
basic_string::size and basic_string::length are synonyms and return the same value.Parameters
noneReturn Value
The number of characters in the string.Member type
size_type is an unsigned integral type.Example
|
|
Output:
The size of str is 11 characters
Complexity
Iterator validity
No changes.Data races
The object is accessed.Exception safety
No-throw guarantee: this member function never throws exceptions.See also
- basic_string::length
- Return length of string (public member function)
- basic_string::resize
- Resize string (public member function)
- basic_string::max_size
- Return maximum size (public member function)
- basic_string::capacity
- Return size of allocated storage (public member function)