I'm following this explanation https://developers.eos.io/eosio-cpp/v1.1.0/docs/multi-index-table-tutorial using v1.5.0 of the CDT. Here's what I've got:
struct [[eosio::table]] order_struct {
name cust;
asset qty;
uint32_t ts;
uint64_t primary_key() const {
return ts;
}
uint64_t matches() const {
return qty.symbol.code().raw();
}
};
typedef eosio::multi_index<
name("orderbook"),
order_struct,
indexed_by<
name("idxmatches"),
const_mem_fun<
order_struct, uint64_t, &order_struct::matches
>
>
> orderbook;
after which I proceed to use the index as prescribed:
orderbook b(_self, _self.value);
auto m = b.get_index<name("idxmatches")>();
for (auto &o : m) {
print(o.cust, " ", o.qty, " ", o.ts, "\n");
}
but this is what I get:
[(t,exchange)->t]: CONSOLE OUTPUT BEGIN =====================
alice 5.00000 NAVC 1549087727
bob 1.00000000 NAVG 1549088004
bob 1.00000000 NAVG 1549088036
alice 3.00000 NAVC 1549087912
bob 7.00000000 NAVG 1549088304
alice 1.00000 NAVC 1549105457
[(t,exchange)->t]: CONSOLE OUTPUT END =====================
which is clearly not sorted. what am I missing?
p.s. the link includes a call to the EOSLIB_SERIALIZE macro. I've tested behaviour with it but it doesn't help
p.p.s. another approach, which I picked up from [https://forum.toshitimes.com/t/advanced-eos-003-table-secondary-indexes/6329] also failed:
auto iter = m.lower_bound(NAVC.code().raw());
while (iter != m.end()) {
print(iter->cust, " ", iter->qty, " ", iter->ts, "\n");
iter++;
}