From 14a93d24e13d77df3c70048b9f40e3e6e6fa306f Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Sun, 1 Jan 2023 18:17:35 -0800 Subject: [PATCH] Common: Add constexpr Fill function --- Source/Core/Common/TypeUtils.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Source/Core/Common/TypeUtils.h b/Source/Core/Common/TypeUtils.h index 47077e11fb..ce2fd516cd 100644 --- a/Source/Core/Common/TypeUtils.h +++ b/Source/Core/Common/TypeUtils.h @@ -83,4 +83,17 @@ static_assert(!IsNOf::value); static_assert(IsNOf::value); static_assert(IsNOf::value); // Type conversions ARE allowed static_assert(!IsNOf::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 's std::fill. Although Dolphin targets C++20, Android doesn't +// seem to properly support constexpr fill(), so we need this for now. +template +constexpr void Fill(std::array& array, const T2& value) +{ + for (auto& entry : array) + { + entry = value; + } +} } // namespace Common