You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The sequences controlled by an object of type `basic_string` are the Standard C++ string class and are referred to as strings, but they shouldn't be confused with the null-terminated C-style strings used throughout the C++ Standard Library. The Standard C++ string is a container that enables the use of strings as normal types, such as comparison and concatenation operations, iterators, C++ Standard Library algorithms, and copying and assigning with class allocator-managed memory. If you need to convert a Standard C++ string to a null-terminated C-style string, use the [`basic_string::c_str`](#c_str) member.
13
13
@@ -18,13 +18,13 @@ template <class CharType, class Traits = char_traits<CharType>, class Allocator
18
18
class basic_string;
19
19
```
20
20
21
-
### Parameters
21
+
### Template parameters
22
22
23
23
*`CharType`*\
24
-
The data type of a single character to be stored in the string. The C++ Standard Library provides specializations of this class template, with the type definitions [`string`](../standard-library/string-typedefs.md#string) for elements of type `char`, [`wstring`](../standard-library/string-typedefs.md#wstring), for `wchar_t`, [`u16string`](../standard-library/string-typedefs.md#u16string) for `char16_t`, and [`u32string`](../standard-library/string-typedefs.md#u32string) for `char32_t`.
24
+
The data type of a single character to be stored in the string. The C++ Standard Library provides specializations of this class template, with the type definitions [`string`](string-typedefs.md#string) for elements of type `char`, [`wstring`](string-typedefs.md#wstring), for `wchar_t`, [`u16string`](string-typedefs.md#u16string) for `char16_t`, and [`u32string`](string-typedefs.md#u32string) for `char32_t`.
25
25
26
26
*`Traits`*\
27
-
Various important properties of the `CharType` elements in a basic_string specialization are described by the class `Traits`. The default value is `char_traits`<`CharType`>.
27
+
Various important properties of the `CharType` elements in a `basic_string` specialization are described by the class `Traits`. The default value is `char_traits`<`CharType`>.
28
28
29
29
*`Allocator`*\
30
30
The type that represents the stored allocator object that encapsulates details about the string's allocation and deallocation of memory. The default value is `allocator<CharType>`.
@@ -117,22 +117,22 @@ The headers that define `basic_string` also define the following [user-defined l
If a function is asked to generate a sequence longer than [`max_size`](#max_size) elements, the function reports a length error by throwing an object of type [`length_error`](../standard-library/length-error-class.md).
127
+
If a function is asked to generate a sequence longer than [`max_size`](#max_size) elements, the function reports a length error by throwing an object of type [`length_error`](length-error-class.md).
128
128
129
129
References, pointers, and iterators that designate elements of the controlled sequence can become invalid after any call to a function that alters the controlled sequence, or after the first call to a non-`const` member function.
@@ -316,7 +316,7 @@ Appending the 1st part of the C-string cstr1b to string str1 gives: Hello Out.
316
316
The string str2c is: Wide World
317
317
The appended string str1 is: Hello World.
318
318
319
-
The string str2d is: Wide
319
+
The string str2d is: Wide
320
320
The appended string str1d is: Hello Wide .
321
321
The doubly appended string str1 is: Hello Wide World .
322
322
@@ -379,10 +379,10 @@ The source string whose characters are to be assigned to the target string.
379
379
The character value to be assigned.
380
380
381
381
*`first`*\
382
-
An input iterator, const_pointer, or const_iterator addressing the first character in the range of the source string to be assigned to the target range.
382
+
An input iterator, `const_pointer`, or `const_iterator` addressing the first character in the range of the source string to be assigned to the target range.
383
383
384
384
*`last`*\
385
-
An input iterator, const_pointer, or const_iterator addressing the one beyond the last character in the range of the source string to be assigned to the target range.
385
+
An input iterator, `const_pointer`, or `const_iterator` addressing the one beyond the last character in the range of the source string to be assigned to the target range.
386
386
387
387
*`off`*\
388
388
The position at which new characters will start to be assigned.
@@ -417,7 +417,7 @@ int main( )
417
417
<< str1a << "." << endl << endl;
418
418
419
419
// The second member function assigning a specific
420
-
// number of the of characters a C-string to a string
420
+
// number of characters of a C-string to a string
421
421
string str1b;
422
422
const char *cstr1b = "Out There";
423
423
cout << "The C-string cstr1b is: " << cstr1b << endl;
@@ -452,7 +452,7 @@ int main( )
452
452
// number of characters of a certain value to a string
453
453
string str1e ( "Hello " );
454
454
str1e.assign ( 4 , '!' );
455
-
cout << "The string str1 assigned with eclamations is: "
455
+
cout << "The string str1 assigned with exclamations is: "
456
456
<< str1e << endl << endl;
457
457
458
458
// The sixth member function assigning the value from
@@ -481,7 +481,7 @@ The string str1 newly assigned with string str2d is: Wide.
481
481
The string str3d is: World.
482
482
The string str1 reassigned with string str3d is: World.
483
483
484
-
The string str1 assigned with eclamations is: !!!!
484
+
The string str1 assigned with exclamations is: !!!!
485
485
486
486
The string str2f is: Wide World
487
487
The string str1 assigned a range of string str2f is: World.
@@ -512,7 +512,7 @@ The first element of the string has an index of zero and the following elements
512
512
513
513
The member [`operator[]`](#op_at) is faster than the member function `at` for providing read and write access to the elements of a string.
514
514
515
-
The member `operator[]` doesn't check whether the index passed as a parameter is valid but the member function `at` does and so should be used if the validity isn't certain. An invalid index, which is an index less that zero or greater than or equal to the size of the string, passed to the member function `at` throws an [`out_of_range` Class](../standard-library/out-of-range-class.md) exception. An invalid index passed to the `operator[]` results in undefined behavior, but the index equal to the length of the string is a valid index for const strings and the operator returns the null-character when passed this index.
515
+
The member `operator[]` doesn't check whether the index passed as a parameter is valid but the member function `at` does and so should be used if the validity isn't certain. An invalid index, which is an index less than zero or greater than or equal to the size of the string, passed to the member function `at` throws an [`out_of_range` Class](out-of-range-class.md) exception. An invalid index passed to the `operator[]` results in undefined behavior, but the index equal to the length of the string is a valid index for const strings and the operator returns the null-character when passed this index.
516
516
517
517
The reference returned may be invalidated by string reallocations or modifications for the non-`const` strings.
518
518
@@ -662,10 +662,10 @@ The index of a character in a string that is the first to be used to initialize
662
662
The character value to be copied into the string being constructed.
663
663
664
664
*`first`*\
665
-
An input iterator, const_pointer, or const_iterator addressing the first element in the source range to be inserted.
665
+
An input iterator, `const_pointer`, or `const_iterator` addressing the first element in the source range to be inserted.
666
666
667
667
*`last`*\
668
-
An input iterator, const_pointer, or const_iterator addressing the position of the one beyond the last element in the source range to be inserted.
668
+
An input iterator, `const_pointer`, or `const_iterator` addressing the position of the one beyond the last element in the source range to be inserted.
669
669
670
670
### Return value
671
671
@@ -1046,7 +1046,7 @@ int compare(
1046
1046
int compare(
1047
1047
size_type position_1,
1048
1048
size_type number_1,
1049
-
const value_type* ptr
1049
+
const value_type* ptr,
1050
1050
size_type number_2) const;
1051
1051
```
1052
1052
@@ -1079,7 +1079,7 @@ A negative value if the operand string is less than the parameter string; zero i
1079
1079
1080
1080
### Remarks
1081
1081
1082
-
The `compare` member functions compare either all, or part, of the parameter and operand strings depending on which in used.
1082
+
The `compare` member functions compare either all, or part, of the parameter and operand strings depending on which is used.
1083
1083
1084
1084
The comparison is case-sensitive.
1085
1085
@@ -1778,7 +1778,7 @@ int main( )
1778
1778
if ( str2.begin( ) == str2.end ( ) )
1779
1779
cout << "The string str2 is empty." << endl;
1780
1780
else
1781
-
cout << "The stringstr2 is not empty." << endl;
1781
+
cout << "The string str2 is not empty." << endl;
1782
1782
}
1783
1783
```
1784
1784
@@ -2447,7 +2447,7 @@ int main( )
2447
2447
<< "position is: " << indexCh3b << endl << endl;
2448
2448
else
2449
2449
cout << "Elements of the substring '5G' were not "
2450
-
<< "found in str3\n after the first occurrrence."
2450
+
<< "found in str3\n after the first occurrence."
2451
2451
<< endl << endl;
2452
2452
2453
2453
// The fourth member function searches a string
@@ -3200,7 +3200,7 @@ The maximum number of characters a string could contain.
3200
3200
3201
3201
### Remarks
3202
3202
3203
-
An exception of type [`length_error` Class](../standard-library/length-error-class.md) is thrown when an operation produces a string with a length greater than the maximum size.
3203
+
An exception of type [`length_error` Class](length-error-class.md) is thrown when an operation produces a string with a length greater than the maximum size.
3204
3204
3205
3205
### Example
3206
3206
@@ -3479,11 +3479,11 @@ The first element of the string has an index of zero, and the following elements
3479
3479
3480
3480
`operator[]` is faster than the member function [`at`](#at) for providing read and write access to the elements of a string.
3481
3481
3482
-
`operator[]` doesn't check whether the index passed as a parameter is valid, but the member function `at` does and so should be used in the validity isn't certain. An invalid index (an index less that zero or greater than or equal to the size of the string) passed to the member function `at` throws an [`out_of_range` Class](../standard-library/out-of-range-class.md) exception. An invalid index passed to `operator[]` results in undefined behavior, but the index equal to the length of the string is a valid index for const strings and the operator returns the null character when passed this index.
3482
+
`operator[]` doesn't check whether the index passed as a parameter is valid, but the member function `at` does and so should be used if the validity isn't certain. An invalid index (an index less than zero or greater than or equal to the size of the string) passed to the member function `at` throws an [`out_of_range` Class](out-of-range-class.md) exception. An invalid index passed to `operator[]` results in undefined behavior, but the index equal to the length of the string is a valid index for const strings and the operator returns the null character when passed this index.
3483
3483
3484
3484
The reference returned may be invalidated by string reallocations or modifications for the non-`const` strings.
3485
3485
3486
-
When compiling with [`_ITERATOR_DEBUG_LEVEL`](../standard-library/iterator-debug-level.md) set to 1 or 2, a runtime error will occur if you attempt to access an element outside the bounds of the string. For more information, see [Checked Iterators](../standard-library/checked-iterators.md).
3486
+
When compiling with [`_ITERATOR_DEBUG_LEVEL`](iterator-debug-level.md) set to 1 or 2, a runtime error will occur if you attempt to access an element outside the bounds of the string. For more information, see [Checked Iterators](checked-iterators.md).
3487
3487
3488
3488
### Example
3489
3489
@@ -3690,7 +3690,7 @@ int main( )
3690
3690
if ( str2.rbegin( ) == str2.rend ( ) )
3691
3691
cout << "The string str2 is empty." << endl;
3692
3692
else
3693
-
cout << "The stringstr2 is not empty." << endl;
3693
+
cout << "The string str2 is not empty." << endl;
3694
3694
}
3695
3695
```
3696
3696
@@ -3788,7 +3788,7 @@ int main( )
3788
3788
if ( str2.rbegin( ) == str2.rend ( ) )
3789
3789
cout << "The string str2 is empty." << endl;
3790
3790
else
3791
-
cout << "The stringstr2 is not empty." << endl;
3791
+
cout << "The string str2 is not empty." << endl;
3792
3792
}
3793
3793
```
3794
3794
@@ -3908,10 +3908,10 @@ An iterator addressing the first character to be removed in the operand string.
3908
3908
An iterator addressing the last character to be removed in the operand string.
3909
3909
3910
3910
*`first`*\
3911
-
An iterator, const_pointer, or const_iterator addressing the first character to be copied in the parameter string.
3911
+
An iterator, `const_pointer`, or `const_iterator` addressing the first character to be copied in the parameter string.
3912
3912
3913
3913
*`last`*\
3914
-
An iterator, const_pointer, or const_iterator addressing the last character to be copied in the parameter string.
3914
+
An iterator, `const_pointer`, or `const_iterator` addressing the last character to be copied in the parameter string.
3915
3915
3916
3916
*`count`*\
3917
3917
The number of times *`char_value`* is copied into the operand string.
@@ -4151,7 +4151,7 @@ int main( )
4151
4151
sizerStr1 = str1.size ( );
4152
4152
caprStr1 = str1.capacity ( );
4153
4153
4154
-
cout << "The string str1with augmented capacity is: "
4154
+
cout << "The string str1 with augmented capacity is: "
4155
4155
<< str1 << endl;
4156
4156
cout << "The current size of string str1 is: "
4157
4157
<< sizerStr1 << "." << endl;
@@ -4180,7 +4180,7 @@ The original string str1 is: Hello world
4180
4180
The current size of original string str1 is: 11.
4181
4181
The capacity of original string str1 is: 15.
4182
4182
4183
-
The string str1with augmented capacity is: Hello world
4183
+
The string str1 with augmented capacity is: Hello world
4184
4184
The current size of string str1 is: 11.
4185
4185
The new capacity of string str1 is: 47.
4186
4186
@@ -4805,7 +4805,7 @@ For type `string`, it's equivalent to `char_traits<char>`.
4805
4805
4806
4806
### Example
4807
4807
4808
-
See the example for [`copy`](../standard-library/char-traits-struct.md#copy) for an example of how to declare and use `traits_type`.
4808
+
See the example for [`copy`](char-traits-struct.md#copy) for an example of how to declare and use `traits_type`.
0 commit comments