Ignore:
Timestamp:
Nov 15, 2023, 11:55:59 AM (7 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
b8b5535
Parents:
1ccae59
Message:

It turns out enumerate does work if you use this very particular form of the for loop added in C++17. Ironically in this simple vector case it is about as complex. Swapped the order of fields in the enuemate value to make the binding read key-then-value.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Common/Iterate.hpp

    r1ccae59 r45a091b  
    5858        template<typename val_t>
    5959        struct value_t {
     60                size_t idx;
    6061                val_t & val;
    61                 size_t idx;
    6262        };
    6363
     
    6969                iterator_t( iter_t _it, size_t _idx ) : it(_it), idx(_idx) {}
    7070
    71                 value_t<val_t> operator*() const { return value_t<val_t>{ *it, idx }; }
     71                value_t<val_t> operator*() const { return value_t<val_t>{ idx, *it }; }
    7272
    7373                bool operator==(const iterator_t & o) const { return o.it == it; }
Note: See TracChangeset for help on using the changeset viewer.