From f9c1a40e21bff9739c9910436d59b25a69538cdf Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Thu, 2 Sep 2021 04:02:43 +0300 Subject: libcamera: base: utils: Use size_t for index in utils::enumerate() The index generated by utils::enumerate() is an iteration counter, which should thus be positive. Use std::size_t instead of the difference_type of the container. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Jean-Michel Hautbois Reviewed-by: Paul Elder Reviewed-by: Hirokazu Honda --- test/utils.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/utils.cpp b/test/utils.cpp index d7f810e9..d65467b5 100644 --- a/test/utils.cpp +++ b/test/utils.cpp @@ -77,8 +77,8 @@ protected: int testEnumerate() { - std::vector integers{ 1, 2, 3, 4, 5 }; - int i = 0; + std::vector integers{ 1, 2, 3, 4, 5 }; + unsigned int i = 0; for (auto [index, value] : utils::enumerate(integers)) { if (index != i || value != i + 1) { @@ -93,12 +93,12 @@ protected: ++i; } - if (integers != std::vector{ 0, 1, 2, 3, 4 }) { + if (integers != std::vector{ 0, 1, 2, 3, 4 }) { cerr << "Failed to modify container in enumerated range loop" << endl; return TestFail; } - Span span{ integers }; + Span span{ integers }; i = 0; for (auto [index, value] : utils::enumerate(span)) { @@ -112,7 +112,7 @@ protected: ++i; } - const int array[] = { 0, 2, 4, 6, 8 }; + const unsigned int array[] = { 0, 2, 4, 6, 8 }; i = 0; for (auto [index, value] : utils::enumerate(array)) { -- cgit v1.2.1