From e5c151c31844b0ee3a4546baae9ee9519953cf61 Mon Sep 17 00:00:00 2001 From: romintomasetti Date: Fri, 23 Oct 2026 13:35:50 +0000 Subject: [PATCH] bulk: check index type contract The index type is deduced from the Shape type. https://eel.is/c++draft/exec#bulk-4 Signed-off-by: romintomasetti --- test/stdexec/algos/adaptors/test_bulk.cpp | 39 +++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/test/stdexec/algos/adaptors/test_bulk.cpp b/test/stdexec/algos/adaptors/test_bulk.cpp index 7a33a458f..1214d38dc 100644 --- a/test/stdexec/algos/adaptors/test_bulk.cpp +++ b/test/stdexec/algos/adaptors/test_bulk.cpp @@ -618,6 +618,45 @@ namespace ex::start(op); } + template + struct CheckIndexType + { + template + void operator()(Deduced const, bool& as_expected) const noexcept + { + as_expected = std::same_as; + } + }; + + TEST_CASE("bulk index type is deduced from shape type", "[adaptors][bulk]") + { + { + // The index type matches. + auto const [value] = + ex::sync_wait(ex::just(false) | ex::bulk(ex::par, int(1), CheckIndexType{})).value(); + CHECK(value == true); + } + { + // The index type does not match. + auto const [value] = + ex::sync_wait(ex::just(true) | ex::bulk(ex::par, int(1), CheckIndexType{})).value(); + CHECK(value == false); + } + { + // The index type matches. + auto const [value] = ex::sync_wait(ex::just(false) + | ex::bulk(ex::par, size_t(1), CheckIndexType{})) + .value(); + CHECK(value == true); + } + { + // The index type does not match. + auto const [value] = + ex::sync_wait(ex::just(true) | ex::bulk(ex::par, size_t(1), CheckIndexType{})).value(); + CHECK(value == false); + } + } + #if !STDEXEC_NO_STDCPP_EXCEPTIONS() TEST_CASE("bulk can throw, and set_error will be called", "[adaptors][bulk]") {