From 278daddd2a4fc07a38a1252c9201ef8b136c313b Mon Sep 17 00:00:00 2001 From: kd-11 Date: Sat, 25 Apr 2026 23:03:09 +0300 Subject: [PATCH] rsx/util: Add a simple wrapper for simple_array::for_each - Just calls std::for_each behind the scenes but it's a lot more convenient --- rpcs3/Emu/RSX/Common/simple_array.hpp | 6 ++++++ rpcs3/tests/test_simple_array.cpp | 15 +++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/rpcs3/Emu/RSX/Common/simple_array.hpp b/rpcs3/Emu/RSX/Common/simple_array.hpp index f2dc15ccdb..d3535c71ff 100644 --- a/rpcs3/Emu/RSX/Common/simple_array.hpp +++ b/rpcs3/Emu/RSX/Common/simple_array.hpp @@ -634,5 +634,11 @@ namespace rsx } return accumulate; } + + template + void for_each(F&& func) + { + std::for_each(begin(), end(), func); + } }; } diff --git a/rpcs3/tests/test_simple_array.cpp b/rpcs3/tests/test_simple_array.cpp index f08455ae00..0222b4fd0d 100644 --- a/rpcs3/tests/test_simple_array.cpp +++ b/rpcs3/tests/test_simple_array.cpp @@ -378,6 +378,21 @@ namespace rsx } } + TEST(SimpleArray, ForEach) + { + rsx::simple_array arr{ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 + }; + arr.for_each(FN(x += 10)); + + EXPECT_EQ(arr.size(), 10); + + for (int i = 0; i < 10; ++i) + { + EXPECT_EQ(arr[i], i + 10); + } + } + TEST(AlignedAllocator, Alloc) { auto ptr = rsx::aligned_allocator::malloc<256>(16);