diff --git a/include/array/array.h b/include/array/array.h index dac1709..9e06b24 100644 --- a/include/array/array.h +++ b/include/array/array.h @@ -1941,29 +1941,29 @@ class copy_shape_traits { * or `sizeof...(LoopOrder)` `index_t` objects in the case of * `for_all_indices<>`. */ template , - std::enable_if_t<(sizeof...(LoopOrder) == 0), int> = 0> + std::enable_if_t<(sizeof...(LoopOrder) == 0), int> = 0, + class = internal::enable_if_callable> NDARRAY_UNIQUE NDARRAY_HOST_DEVICE void for_each_index(const Shape& s, Fn&& fn) { shape_traits::for_each_index(s, fn); } template , - std::enable_if_t<(sizeof...(LoopOrder) == 0), int> = 0> + std::enable_if_t<(sizeof...(LoopOrder) == 0), int> = 0, + class = internal::enable_if_applicable> NDARRAY_UNIQUE NDARRAY_HOST_DEVICE void for_all_indices(const Shape& s, Fn&& fn) { using index_type = typename Shape::index_type; for_each_index(s, [fn = std::move(fn)](const index_type& i) { internal::apply(fn, i); }); } template >, - std::enable_if_t<(sizeof...(LoopOrder) != 0), int> = 0> + std::enable_if_t<(sizeof...(LoopOrder) != 0), int> = 0, + class = internal::enable_if_callable>> NDARRAY_UNIQUE NDARRAY_HOST_DEVICE void for_each_index(const Shape& s, Fn&& fn) { using index_type = index_of_rank; for_each_index_in_order(reorder(s), [fn = std::move(fn)](const index_type& i) { fn(internal::unshuffle(i)); }); } template , - std::enable_if_t<(sizeof...(LoopOrder) != 0), int> = 0> + std::enable_if_t<(sizeof...(LoopOrder) != 0), int> = 0, + class = internal::enable_if_callable> NDARRAY_UNIQUE NDARRAY_HOST_DEVICE void for_all_indices(const Shape& s, Fn&& fn) { using index_type = index_of_rank; for_each_index_in_order(reorder(s), [fn = std::move(fn)](const index_type& i) { diff --git a/test/shape.cpp b/test/shape.cpp index 681bc93..2d3f3aa 100644 --- a/test/shape.cpp +++ b/test/shape.cpp @@ -337,7 +337,7 @@ TEST(for_each_index_scalar) { TEST(for_each_index_1d) { dense_shape<1> s(20); int expected_flat_offset = 0; - for_each_index(s, [&](std::tuple i) { + for_each_index(s, [&](auto i) { ASSERT_EQ(s[i], expected_flat_offset); expected_flat_offset++; }); @@ -362,7 +362,7 @@ TEST(for_each_index_3d) { s.resolve(); int expected_flat_offset = 0; move_only token; - for_each_index(s, [&, token = std::move(token)](std::tuple i) { + for_each_index(s, [&, token = std::move(token)](auto i) { ASSERT_EQ(s[i], expected_flat_offset); expected_flat_offset++; assert_used(token);