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);