Skip to content

Commit

Permalink
[math] Fix enumerate() when range reference type is not a reference
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-durand committed Feb 6, 2024
1 parent 5ecda11 commit 76b4e1a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/modm/math/algorithm/enumerate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@

#pragma once

#include <stdint.h>
#include <cstdint>
#include <ranges>
#include <tuple>
#include <utility>

namespace modm
{
Expand All @@ -31,7 +33,10 @@ constexpr auto enumerate(T && iterable)
TIter iter;
constexpr bool operator != (const iterator & other) const { return iter != other.iter; }
constexpr void operator ++ () { ++i; ++iter; }
constexpr auto operator * () const { return std::tie(i, *iter); }
constexpr auto operator * () const
{
return std::tuple<size_t, std::ranges::range_reference_t<T>>{i, *iter};
}
};
struct iterable_wrapper
{
Expand Down

0 comments on commit 76b4e1a

Please sign in to comment.