From 34c88e3f462a61024a6798e946fe03ee6fe2a11b Mon Sep 17 00:00:00 2001 From: Pascal Thomet Date: Tue, 11 Jun 2024 17:38:49 +0200 Subject: [PATCH] unweave: Fix for MSVC 2022 ARM Preview probable compiler bug See https://stackoverflow.com/questions/78608330/postfix-increment-compiler-bug-on-visual-studio-2022-arm-preview?noredirect=1#comment138587024_78608330 --- include/fplus/container_common.hpp | 3 ++- include_all_in_one/include/fplus/fplus.hpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/fplus/container_common.hpp b/include/fplus/container_common.hpp index 540d4b28..8a375569 100644 --- a/include/fplus/container_common.hpp +++ b/include/fplus/container_common.hpp @@ -1278,10 +1278,11 @@ std::pair unweave(const Container& xs) auto it_odd = internal::get_back_inserter(result.second); std::size_t counter = 0; for (const auto& x : xs) { - if (counter++ % 2 == 0) + if (counter % 2 == 0) *it_even = x; else *it_odd = x; + counter++; } return result; } diff --git a/include_all_in_one/include/fplus/fplus.hpp b/include_all_in_one/include/fplus/fplus.hpp index 06530c00..799b670d 100644 --- a/include_all_in_one/include/fplus/fplus.hpp +++ b/include_all_in_one/include/fplus/fplus.hpp @@ -4373,10 +4373,11 @@ std::pair unweave(const Container& xs) auto it_odd = internal::get_back_inserter(result.second); std::size_t counter = 0; for (const auto& x : xs) { - if (counter++ % 2 == 0) + if (counter % 2 == 0) *it_even = x; else *it_odd = x; + counter++; } return result; }