Kommentar
Åtkomst till den här sidan kräver auktorisering. Du kan prova att logga in eller ändra kataloger.
Åtkomst till den här sidan kräver auktorisering. Du kan prova att ändra kataloger.
An unsigned integer type that can represent the number of elements and indices in a string.
typedef typename allocator_type::size_type size_type;
Remarks
It is equivalent to allocator_type::size_type.
For type string, it is equivalent to size_t.
Example
// basic_string_size_type.cpp
// compile with: /EHsc
#include <string>
#include <iostream>
int main( )
{
using namespace std;
string str1 ( "Hello world" );
basic_string <char>::size_type sizeStr1, capStr1;
sizeStr1 = str1.size ( );
capStr1 = str1.capacity ( );
cout << "The current size of string str1 is: "
<< sizeStr1 << "." << endl;
cout << "The capacity of string str1 is: " << capStr1
<< "." << endl;
}
The current size of string str1 is: 11. The capacity of string str1 is: 15.
Requirements
Header: <string>
Namespace: std