1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-27 00:11:17 +02:00

Rework a few things with the experimental features list

- Use struct not `std::pair`, designated initializers

- Use `constexpr` array that we can index by enum tag

- It no longer segfaults; not sure why.
This commit is contained in:
John Ericson 2023-04-02 18:11:16 -04:00
parent b2c9315bf2
commit 2585bcaa50
3 changed files with 142 additions and 82 deletions

View file

@ -730,16 +730,16 @@ constexpr auto enumerate(T && iterable)
{
size_t i;
TIter iter;
bool operator != (const iterator & other) const { return iter != other.iter; }
void operator ++ () { ++i; ++iter; }
auto operator * () const { return std::tie(i, *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); }
};
struct iterable_wrapper
{
T iterable;
auto begin() { return iterator{ 0, std::begin(iterable) }; }
auto end() { return iterator{ 0, std::end(iterable) }; }
constexpr auto begin() { return iterator{ 0, std::begin(iterable) }; }
constexpr auto end() { return iterator{ 0, std::end(iterable) }; }
};
return iterable_wrapper{ std::forward<T>(iterable) };