…ations
The per-chunk lambdas of set_union, set_intersection, set_difference and
set_symmetric_difference declared the end of each chunk as Sent1/Sent2,
but set_operation() calls them with chunk-end iterators (first1 + end1).
That only compiles when the sentinel type equals the iterator type, so
the iterator/sentinel overloads with a par or par(task) policy (which
require a sized sentinel) were ill-formed for any other sentinel type,
while seq worked. Declare the chunk ends as Iter1/Iter2.
Add set_operations_sentinel_range, which runs all four operations with
a sized sentinel under seq, par and both task policies and compares the
output with the std:: algorithms.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Arnab Chatterjee <arnabchatterjee281205@gmail.com>
Fixes #8249
Proposed Changes
set_union.hpp,set_intersection.hpp,set_difference.hppandset_symmetric_difference.hpp, declare the end of each chunk in the per-chunk lambdaf2asIter1/Iter2instead ofSent1/Sent2.detail::set_operation()calls the lambda with chunk-end iterators (first1 + end1,first2 + end2), which only converted to the parameter type when the sentinel type happened to equal the iterator type. With apar/par(task)policy (which requires a sized sentinel) and any other sentinel type the iterator/sentinel overloads were ill-formed;seqwas fine.set_operations_sentinel_range, which runs all four operations with a sized sentinel of a different type underseq,parand both task policies and compares the output withstd::set_union,std::set_intersection,std::set_differenceandstd::set_symmetric_difference.Any background context you want to provide?
The change is 8 lines plus the new test. A minimal reproducer is in #8249.
It does not touch the code that #7933 changes (the input iterators returned by
set_operation()), so the two should not conflict.Tested locally (Debug, GCC 15.2,
-std=c++23): the new test fails to compile on the original headers (no match for call to ... set_operation.hpp:139) and passes with the change;set_union_range,set_intersection_range,set_difference_range,set_symmetric_difference_range,includes_rangeandmerge_rangestill pass. Not tried with clang/MSVC. Noclang-formatwas available here, so lines were wrapped by hand; I will push any formatting fixes CI asks for as a normal commit.I used Claude Code to help find this bug, write the fix and the test, and write this description, and I reviewed the diff.
Checklist