From 3d64461339e3fd13158e2f519094879b80039223 Mon Sep 17 00:00:00 2001 From: Rageking8 <106309953+Rageking8@users.noreply.github.com> Date: Mon, 18 Aug 2025 23:57:27 +0800 Subject: [PATCH 1/4] Fix some typos in `` functions reference --- docs/standard-library/algorithm-functions.md | 36 ++++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/docs/standard-library/algorithm-functions.md b/docs/standard-library/algorithm-functions.md index b243d2c1ebb..7e55579a809 100644 --- a/docs/standard-library/algorithm-functions.md +++ b/docs/standard-library/algorithm-functions.md @@ -595,7 +595,7 @@ An output iterator addressing the position that is one past the final element in The source range must be valid and there must be sufficient space at the destination to hold all the elements being copied. -The `copy_backward` algorithm imposes more stringent requirements than that the `copy` algorithm. Both its input and output iterators must be bidirectional. +The `copy_backward` algorithm imposes more stringent requirements than the `copy` algorithm. Both its input and output iterators must be bidirectional. The `copy_backward` and [`move_backward`](algorithm-functions.md#move_backward) algorithms are the only C++ Standard Library algorithms designating the output range with an iterator pointing to the end of the destination range. @@ -908,13 +908,13 @@ int main() vector::iterator::difference_type result; result = count(v1.begin(), v1.end(), 10); - cout << "The number of 10s in v2 is: " << result << "." << endl; + cout << "The number of 10s in v1 is: " << result << "." << endl; } ``` ```Output v1 = ( 10 20 10 40 10 ) -The number of 10s in v2 is: 3. +The number of 10s in v1 is: 3. ``` ## `count_if` @@ -2149,7 +2149,7 @@ public: { } - // The function call to process the next elment + // The function call to process the next element void operator( ) ( int elem ) { num++; // Increment the element count @@ -2686,7 +2686,7 @@ int main() cout << *Iter3b << " "; cout << ")." << endl; - // To test for inclusion under an asscending order + // To test for inclusion under an ascending order // with the default binary predicate less( ) bool Result1; Result1 = includes ( v1a.begin( ), v1a.end( ), @@ -5933,7 +5933,7 @@ int main() cout << *Iter1 << " "; cout << ")." << endl; - // Partition the range with predicate greater10 + // Partition the range with predicate greater5 partition ( v1.begin( ), v1.end( ), greater5 ); cout << "The partitioned set of elements in v1 is: ( " ; for ( Iter1 = v1.begin( ) ; Iter1 != v1.end( ) ; Iter1++ ) @@ -6694,7 +6694,7 @@ An input iterator addressing the position one past the final element in the rang An output iterator addressing the position of the first element in the destination range to which elements are being removed. *`pred`*\ -The unary predicate that must be satisfied is the value of an element is to be replaced. +The unary predicate that must be satisfied if the value of an element is to be replaced. ### Return value @@ -6751,7 +6751,7 @@ int main() new_end = remove_copy_if ( v1.begin( ), v1.end( ), v2.begin( ), greater6 ); - cout << "After the appliation of remove_copy_if to v1,\n " + cout << "After the application of remove_copy_if to v1,\n " << "vector v1 is left unchanged as ( " ; for ( Iter1 = v1.begin( ) ; Iter1 != v1.end( ) ; Iter1++ ) cout << *Iter1 << " "; @@ -6767,7 +6767,7 @@ int main() ```Output The original vector v1 is: ( 4 7 7 7 0 5 7 1 6 9 3 7 8 2 ). -After the appliation of remove_copy_if to v1, +After the application of remove_copy_if to v1, vector v1 is left unchanged as ( 4 7 7 7 0 5 7 1 6 9 3 7 8 2 ). Vector v2 is a copy of v1 with values greater than 6 removed: ( 4 0 5 1 6 3 2 ). @@ -6804,7 +6804,7 @@ A forward iterator pointing to the position of the first element in the range fr A forward iterator pointing to the position one past the final element in the range from which elements are being removed. *`pred`*\ -The unary predicate that must be satisfied is the value of an element is to be replaced. +The unary predicate that must be satisfied if the value of an element is to be replaced. ### Return value @@ -7148,7 +7148,7 @@ An input iterator pointing to the position one past the final element in the ran An output iterator pointing to the position of the first element in the destination range to which elements are being copied. *`pred`*\ -The unary predicate that must be satisfied is the value of an element is to be replaced. +The unary predicate that must be satisfied if the value of an element is to be replaced. *`value`*\ The new value being assigned to the elements whose old value satisfies the predicate. @@ -7277,7 +7277,7 @@ A forward iterator pointing to the position of the first element in the range fr An iterator pointing to the position one past the final element in the range from which elements are being replaced. *`pred`*\ -The unary predicate that must be satisfied is the value of an element is to be replaced. +The unary predicate that must be satisfied if the value of an element is to be replaced. *`value`*\ The new value being assigned to the elements whose old value satisfies the predicate. @@ -8269,7 +8269,7 @@ int main() cout << *Iter3b << " "; cout << ")." << endl; - // To combine into a difference in asscending + // To combine into a difference in ascending // order with the default binary predicate less( ) Result1 = set_difference ( v1a.begin( ), v1a.end( ), v1b.begin( ), v1b.end( ), v1.begin( ) ); @@ -8488,7 +8488,7 @@ int main() cout << *Iter3b << " "; cout << ")." << endl; - // To combine into an intersection in asscending order with the + // To combine into an intersection in ascending order with the // default binary predicate less( ) Result1 = set_intersection ( v1a.begin( ), v1a.end( ), v1b.begin( ), v1b.end( ), v1.begin( ) ); @@ -9170,7 +9170,7 @@ Heaps have two properties: - Elements may be added or removed in logarithmic time. -After the application if this algorithm, the range it was applied to is no longer a heap. +After the application of this algorithm, the range it was applied to is no longer a heap. `sort_heap` isn't a stable sort because the relative order of equivalent elements isn't necessarily preserved. @@ -9585,7 +9585,7 @@ A forward iterator pointing to one past the final position of the second range w The ranges referenced must be valid; all pointers must be dereferenceable and within each sequence the last position is reachable from the first by incrementation. The second range has to be as large as the first range. -The complexity is linear with *last1* - *first1* swaps performed. If elements from containers of the same type are being swapped, them the `swap` member function from that container should be used, because the member function typically has constant complexity. +The complexity is linear with *last1* - *first1* swaps performed. If elements from containers of the same type are being swapped, then the `swap` member function from that container should be used, because the member function typically has constant complexity. ### Example @@ -9922,7 +9922,7 @@ int main() cout << *v1_Iter1 << " "; cout << ")." << endl; - // Remove consecutive duplicates under the binary prediate mod_equals + // Remove consecutive duplicates under the binary predicate mod_equals v1_NewEnd2 = unique ( v1.begin( ), v1_NewEnd1 , mod_equal ); cout << "Removing adjacent duplicates from vector v1 under the\n " @@ -10078,7 +10078,7 @@ int main() { for ( iv = 0 ; iv <= 7 ; iv++ ) v1.push_back( 10 ); - // Remove consecutive duplicates under the binary prediate mod_equals + // Remove consecutive duplicates under the binary predicate mod_equals v1_NewEnd2 = unique_copy ( v1.begin( ), v1.begin( ) + 14, v1.begin( ) + 14 , mod_equal ); From 03ace2f09fd358b6e1f6c42867b7b8b6ee2a3d0a Mon Sep 17 00:00:00 2001 From: Rageking8 <106309953+Rageking8@users.noreply.github.com> Date: Tue, 19 Aug 2025 00:00:34 +0800 Subject: [PATCH 2/4] Clean up duplicate semicolons in `` functions reference --- docs/standard-library/algorithm-functions.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/standard-library/algorithm-functions.md b/docs/standard-library/algorithm-functions.md index 7e55579a809..3865864df02 100644 --- a/docs/standard-library/algorithm-functions.md +++ b/docs/standard-library/algorithm-functions.md @@ -2892,7 +2892,7 @@ int main() // Applying a user defined (UD) binary predicate mod_lesser inplace_merge ( v3.begin( ), break3, v3.end( ), mod_lesser ); cout << "Merged inplace with binary predicate mod_lesser specified,\n " - << "vector v3mod = ( " ; ; + << "vector v3mod = ( " ; for ( Iter3 = v3.begin( ) ; Iter3 != v3.end( ) ; Iter3++ ) cout << *Iter3 << " "; cout << ")" << endl; @@ -4424,7 +4424,7 @@ int main() { merge ( v3a.begin( ), v3a.end( ), v3b.begin( ), v3b.end( ), v3.begin( ), mod_lesser ); cout << "Merged inplace with binary predicate mod_lesser specified,\n " - << "vector v3mod = ( " ; ; + << "vector v3mod = ( " ; for ( Iter3 = v3.begin( ) ; Iter3 != v3.end( ) ; Iter3++ ) cout << *Iter3 << " "; cout << ")." << endl; @@ -8294,7 +8294,7 @@ int main() Result3 = set_difference ( v3a.begin( ), v3a.end( ), v3b.begin( ), v3b.end( ), v3.begin( ), mod_lesser ); cout << "Set_difference of source ranges with binary " - << "predicate mod_lesser specified,\n vector v3mod = ( " ; ; + << "predicate mod_lesser specified,\n vector v3mod = ( " ; for ( Iter3 = v3.begin( ) ; Iter3 != Result3 ; Iter3++ ) cout << *Iter3 << " "; cout << ")." << endl; @@ -8513,7 +8513,7 @@ int main() Result3 = set_intersection ( v3a.begin( ), v3a.end( ), v3b.begin( ), v3b.end( ), v3.begin( ), mod_lesser ); cout << "Intersection of source ranges with binary predicate " - << "mod_lesser specified,\n vector v3mod = ( " ; ; + << "mod_lesser specified,\n vector v3mod = ( " ; for ( Iter3 = v3.begin( ) ; Iter3 != Result3 ; ++Iter3 ) cout << *Iter3 << " "; cout << ")." << endl; @@ -8736,7 +8736,7 @@ int main() Result3 = set_symmetric_difference ( v3a.begin( ), v3a.end( ), v3b.begin( ), v3b.end( ), v3.begin( ), mod_lesser ); cout << "Set_symmetric_difference of source ranges with binary " - << "predicate mod_lesser specified,\n vector v3mod = ( " ; ; + << "predicate mod_lesser specified,\n vector v3mod = ( " ; for ( Iter3 = v3.begin( ) ; Iter3 != Result3 ; Iter3++ ) cout << *Iter3 << " "; cout << ")." << endl; @@ -8959,7 +8959,7 @@ int main() Result3 = set_union ( v3a.begin( ), v3a.end( ), v3b.begin( ), v3b.end( ), v3.begin( ), mod_lesser ); cout << "Union of source ranges with binary predicate " - << "mod_lesser specified,\n vector v3mod = ( " ; ; + << "mod_lesser specified,\n vector v3mod = ( " ; for ( Iter3 = v3.begin( ) ; Iter3 != Result3 ; Iter3++ ) cout << *Iter3 << " "; cout << ")." << endl; From 24da214979feee1f2b850c8d2cea7d661bf61750 Mon Sep 17 00:00:00 2001 From: Rageking8 <106309953+Rageking8@users.noreply.github.com> Date: Tue, 19 Aug 2025 00:03:56 +0800 Subject: [PATCH 3/4] Remove 1 double and trailing space in `` functions reference --- docs/standard-library/algorithm-functions.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/standard-library/algorithm-functions.md b/docs/standard-library/algorithm-functions.md index 3865864df02..976e06b9fac 100644 --- a/docs/standard-library/algorithm-functions.md +++ b/docs/standard-library/algorithm-functions.md @@ -2292,7 +2292,7 @@ public: } }; -// Utility to display the contents of a vector +// Utility to display the contents of a vector template void print_vector(const std::vector &vec) { std::cout << "( "; @@ -6660,7 +6660,7 @@ Vector v2 is a copy of v1 with the value 7 removed: ## `remove_copy_if` -Copies elements from a source range to a destination range, except for elements that satisfy a predicate. Elements are copied without disturbing the order of the remaining elements. Returns the end of a new destination range. +Copies elements from a source range to a destination range, except for elements that satisfy a predicate. Elements are copied without disturbing the order of the remaining elements. Returns the end of a new destination range. ```cpp template From 613193555701587060c76b4585aa69b44c166f55 Mon Sep 17 00:00:00 2001 From: Rageking8 <106309953+Rageking8@users.noreply.github.com> Date: Tue, 19 Aug 2025 00:06:27 +0800 Subject: [PATCH 4/4] Fix extraneous `>` in `mismatch` syntax in `` functions reference --- docs/standard-library/algorithm-functions.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/standard-library/algorithm-functions.md b/docs/standard-library/algorithm-functions.md index 976e06b9fac..65b150d64e8 100644 --- a/docs/standard-library/algorithm-functions.md +++ b/docs/standard-library/algorithm-functions.md @@ -4949,13 +4949,14 @@ Use the dual-range overloads in C++14 code because the overloads that only take ```cpp template -pair> +pair mismatch( InputIterator1 first1, InputIterator1 last1, InputIterator2 first2 ); -template pair> +template +pair mismatch( InputIterator1 first1, InputIterator1 last1, @@ -4964,14 +4965,15 @@ mismatch( //C++14 template -pair> +pair mismatch( InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2 ); -template pair> +template +pair mismatch( InputIterator1 first1, InputIterator1 last1,