Skip to content

Perfect forwarding of execution policy in tests #2308

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 17, 2025

Conversation

SergeyKopienko
Copy link
Contributor

@SergeyKopienko SergeyKopienko commented Jun 11, 2025

This PR updates test cases to perfectly forward execution policies using std::forward and fixes spelling mistakes in comments.

  • Introduce std::forward<Policy>(exec) (or ExecutionPolicy) in various algorithm test calls to preserve value category.
  • Corrected typos in comments (“itertors” → “iterators”).

@SergeyKopienko SergeyKopienko added this to the 2022.10.0 milestone Jun 11, 2025
@SergeyKopienko SergeyKopienko added test Test only Change enhancement and removed enhancement labels Jun 11, 2025
@SergeyKopienko SergeyKopienko force-pushed the dev/skopienko/forward_policy_in_tests branch 2 times, most recently from d51f389 to 93ced22 Compare June 12, 2025 09:41
@SergeyKopienko SergeyKopienko requested a review from Copilot June 12, 2025 09:48
Copilot

This comment was marked as outdated.

@SergeyKopienko SergeyKopienko force-pushed the dev/skopienko/forward_policy_in_tests branch 3 times, most recently from 2f1f5db to 49b1713 Compare June 13, 2025 13:56
@SergeyKopienko SergeyKopienko requested a review from Copilot June 13, 2025 14:39
Copilot

This comment was marked as outdated.

@SergeyKopienko SergeyKopienko requested a review from Copilot June 16, 2025 08:51
Copilot

This comment was marked as outdated.

@SergeyKopienko SergeyKopienko force-pushed the dev/skopienko/forward_policy_in_tests branch from 5e925f1 to a899601 Compare June 16, 2025 10:04
@SergeyKopienko SergeyKopienko requested a review from Copilot June 16, 2025 10:06
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR ensures that execution policies are perfectly forwarded in test cases by wrapping algorithm calls with std::forward, and also fixes spelling errors in test comments.

  • Perfect forwarding of execution policy parameters has been introduced across various algorithm test calls.
  • Spelling mistakes in test comments (e.g., “itertors” to “iterators”) have been corrected.

Reviewed Changes

Copilot reviewed 71 out of 71 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/parallel_api/algorithm/alg.modifying.operations/swap_ranges.pass.cpp Updated swap_ranges call to use std::forward(exec)
test/parallel_api/algorithm/alg.modifying.operations/shift_left_right.pass.cpp Updated shift_left_right call and corrected spelling in comments
test/parallel_api/algorithm/alg.modifying.operations/rotate_copy.pass.cpp Updated rotate_copy call to use std::forward(exec)
test/parallel_api/algorithm/alg.modifying.operations/replace_copy.pass.cpp Updated replace_copy and replace_copy_if calls with std::forward forwarding
test/parallel_api/algorithm/alg.modifying.operations/replace.pass.cpp Updated replace and replace_if calls with std::forward forwarding
test/parallel_api/algorithm/alg.modifying.operations/remove_copy.pass.cpp Updated remove_copy call to use std::forward forwarding
test/parallel_api/algorithm/alg.modifying.operations/remove.pass.cpp Updated remove and remove_if calls with std::forward forwarding
test/parallel_api/algorithm/alg.modifying.operations/generate.pass.cpp Updated generate and generate_n calls with std::forward forwarding
test/parallel_api/algorithm/alg.modifying.operations/fill.pass.cpp Updated fill call with std::forward forwarding
test/parallel_api/algorithm/alg.modifying.operations/copy_move.pass.cpp Updated copy, copy_n, and move calls with std::forward forwarding
test/parallel_api/algorithm/alg.modifying.operations/alg.reverse/reverse_copy.pass.cpp Updated reverse_copy call with std::forward forwarding
test/parallel_api/algorithm/alg.modifying.operations/alg.reverse/reverse.pass.cpp Updated reverse call with std::forward forwarding
test/parallel_api/algorithm/alg.modifying.operations/alg.partitions/stable_partition.pass.cpp Updated stable_partition call with std::forward forwarding
test/parallel_api/algorithm/alg.modifying.operations/alg.partitions/partition_copy.pass.cpp Updated partition_copy call with std::forward forwarding
test/parallel_api/algorithm/alg.modifying.operations/alg.partitions/partition.pass.cpp Updated partition call with std::forward forwarding
test/parallel_api/algorithm/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp Updated is_partitioned call with std::forward forwarding
test/parallel_api/algorithm/alg.modifying.operations/alg.copy/copy_if.pass.cpp Updated copy_if and remove_copy_if calls with std::forward forwarding
test/parallel_api/algorithm/alg.merge/merge.pass.cpp Updated merge calls with std::forward forwarding
test/parallel_api/algorithm/alg.merge/inplace_merge.pass.cpp Updated inplace_merge calls with std::forward forwarding
test/general/test_policies.pass.cpp Updated test_policy_instance call to use std::forward forwarding in fill
Comments suppressed due to low confidence (2)

test/parallel_api/algorithm/alg.modifying.operations/swap_ranges.pass.cpp:105

  • [nitpick] In this file the execution policy is forwarded using std::forward(exec), while in several other test files the template parameter is named 'Policy'. Consider unifying the naming of the execution policy type across all tests for improved clarity.
Iterator2 actual_return = swap_ranges(std::forward<ExecutionPolicy>(exec), data_b, data_e, actual_b);

test/parallel_api/algorithm/alg.modifying.operations/shift_left_right.pass.cpp:64

  • [nitpick] Here the execution policy is forwarded as std::forward(exec). Consider aligning the template parameter name with other tests (e.g., using either 'Policy' or 'ExecutionPolicy' consistently) to avoid potential confusion.
It res = algo(::std::forward<Policy>(exec), first, ::std::next(first, m), n);

Copy link
Contributor

@dmitriy-sobolev dmitriy-sobolev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

I've checked that introduced std::forward are used with forwarding references, and that they are not used multiple times for the same object.

I haven't checked if all possible places are covered, but I trust Sergey here given the scope and coverage of the PR.

@SergeyKopienko SergeyKopienko merged commit 9b288bd into main Jun 17, 2025
19 checks passed
@SergeyKopienko SergeyKopienko deleted the dev/skopienko/forward_policy_in_tests branch June 17, 2025 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test Test only Change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants