Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
views.h
1// SPDX-FileCopyrightText: © 2025-2026 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include <cstddef>
7#include <ranges>
8#include <utility>
9
10namespace zrythm::utils::views
11{
12
13// Range adaptor closure for enumerate - uses zip with iota
14struct EnumerateAdaptor : std::ranges::range_adaptor_closure<EnumerateAdaptor>
15{
16 template <std::ranges::viewable_range Range> auto operator() (Range &&r) const
17 {
18 return std::views::zip (
19 std::views::iota (std::size_t{ 0 }), std::forward<Range> (r));
20 }
21};
22
23// The enumerate function is a range adaptor closure
24inline constexpr EnumerateAdaptor enumerate{};
25
26} // namespace zrythm::utils::views