From 4fbc6de2cf14c0461bbb4c384aab14660b56e598 Mon Sep 17 00:00:00 2001 From: Brede Johansen Date: Fri, 19 Jun 2026 12:48:52 +0200 Subject: [PATCH 1/2] Fix warnings from std::accumulate in xbuilder --- include/xtensor/generators/xbuilder.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/xtensor/generators/xbuilder.hpp b/include/xtensor/generators/xbuilder.hpp index 4b9bed942..4695a64a7 100644 --- a/include/xtensor/generators/xbuilder.hpp +++ b/include/xtensor/generators/xbuilder.hpp @@ -520,7 +520,7 @@ namespace xt const size_t stride = std::accumulate( shape.begin() + i + 1, shape.end(), - 1, + size_t(1), std::multiplies() ); if (i == axis) From bfbf0212c2dfae246f15772efd56a48747412256 Mon Sep 17 00:00:00 2001 From: Brede Johansen Date: Fri, 19 Jun 2026 12:50:27 +0200 Subject: [PATCH 2/2] Use std::size_t in xbuilder --- include/xtensor/generators/xbuilder.hpp | 26 ++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/include/xtensor/generators/xbuilder.hpp b/include/xtensor/generators/xbuilder.hpp index 4695a64a7..1026b21c7 100644 --- a/include/xtensor/generators/xbuilder.hpp +++ b/include/xtensor/generators/xbuilder.hpp @@ -499,7 +499,7 @@ namespace xt { // trim off extra indices if provided to match behavior of containers auto dim_offset = std::distance(first, last) - std::get<0>(t).dimension(); - size_t axis_dim = *(first + axis + dim_offset); + std::size_t axis_dim = *(first + axis + dim_offset); auto match = [&](auto& arr) { if (axis_dim >= arr.shape()[axis]) @@ -512,16 +512,16 @@ namespace xt auto get = [&](auto& arr) { - size_t offset = 0; - const size_t end = arr.dimension(); - for (size_t i = 0; i < end; i++) + std::size_t offset = 0; + const std::size_t end = arr.dimension(); + for (std::size_t i = 0; i < end; i++) { const auto& shape = arr.shape(); - const size_t stride = std::accumulate( + const std::size_t stride = std::accumulate( shape.begin() + i + 1, shape.end(), size_t(1), - std::multiplies() + std::multiplies() ); if (i == axis) { @@ -563,21 +563,21 @@ namespace xt { auto get_item = [&](auto& arr) { - size_t offset = 0; - const size_t end = arr.dimension(); - size_t after_axis = 0; - for (size_t i = 0; i < end; i++) + std::size_t offset = 0; + const std::size_t end = arr.dimension(); + std::size_t after_axis = 0; + for (std::size_t i = 0; i < end; i++) { if (i == axis) { after_axis = 1; } const auto& shape = arr.shape(); - const size_t stride = std::accumulate( + const std::size_t stride = std::accumulate( shape.begin() + static_cast(i) + 1, shape.end(), - size_t(1), - std::multiplies() + std::size_t(1), + std::multiplies() ); const auto len = (*(first + static_cast(i + after_axis))); offset += len * stride;