mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-20 18:40:51 +00:00
Common: Add constexpr Fill function
This commit is contained in:
parent
6b545eaada
commit
14a93d24e1
@ -83,4 +83,17 @@ static_assert(!IsNOf<int, 1, int, int>::value);
|
|||||||
static_assert(IsNOf<int, 2, int, int>::value);
|
static_assert(IsNOf<int, 2, int, int>::value);
|
||||||
static_assert(IsNOf<int, 2, int, short>::value); // Type conversions ARE allowed
|
static_assert(IsNOf<int, 2, int, short>::value); // Type conversions ARE allowed
|
||||||
static_assert(!IsNOf<int, 2, int, char*>::value);
|
static_assert(!IsNOf<int, 2, int, char*>::value);
|
||||||
|
|
||||||
|
// TODO: This can be replaced with std::array's fill() once C++20 is fully supported.
|
||||||
|
// Prior to C++20, std::array's fill() function is, unfortunately, not constexpr.
|
||||||
|
// Ditto for <algorithm>'s std::fill. Although Dolphin targets C++20, Android doesn't
|
||||||
|
// seem to properly support constexpr fill(), so we need this for now.
|
||||||
|
template <typename T1, size_t N, typename T2>
|
||||||
|
constexpr void Fill(std::array<T1, N>& array, const T2& value)
|
||||||
|
{
|
||||||
|
for (auto& entry : array)
|
||||||
|
{
|
||||||
|
entry = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
} // namespace Common
|
} // namespace Common
|
||||||
|
Loading…
x
Reference in New Issue
Block a user