rsx/util: Add a simple wrapper for simple_array<T>::for_each

- Just calls std::for_each behind the scenes but it's a lot more convenient
This commit is contained in:
kd-11 2026-04-25 23:03:09 +03:00 committed by kd-11
parent 48e2d808c9
commit 278daddd2a
2 changed files with 21 additions and 0 deletions

View file

@ -634,5 +634,11 @@ namespace rsx
}
return accumulate;
}
template <typename F>
void for_each(F&& func)
{
std::for_each(begin(), end(), func);
}
};
}

View file

@ -378,6 +378,21 @@ namespace rsx
}
}
TEST(SimpleArray, ForEach)
{
rsx::simple_array<int> 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);