/* SPDX-FileCopyrightText: 2024 Blender Authors * * SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup bli */ #pragma once #include #include namespace blender { template constexpr void unroll_impl(Fn fn, std::index_sequence /*indices*/) { (fn(I), ...); } /** * Variadic templates are used to unroll loops manually. This helps GCC avoid branching during math * operations and makes the code generation more explicit and predictable. Unrolling should always * be worth it because the vector size is expected to be small. */ template constexpr void unroll(Fn fn) { unroll_impl(fn, std::make_index_sequence()); } } // namespace blender