std::basic_string::size, std::basic_string::length
From cppreference.com
< cpp | string | basic string
size_type size() const; |
||
size_type length() const; |
||
Returns the number of CharT
elements in the string, i.e. std::distance(begin(), end()).
Parameters
(none)
Return value
The number of CharT
elements in the string.
Exceptions
(none) | (until C++11) |
noexcept specification: noexcept |
(since C++11) |
Complexity
Constant
Notes
For std::string, the elements are bytes (objects of type char), which are not the same as characters if a multibyte encoding such as UTF-8 is used.