lokinet/llarp/iwp
Jason Rhinelander 36792d4337
Fix multi-field < ordering
Lots and lots of places in the code had broken < operators because they
are returning something like:

    foo < other.foo or bar < other.bar;

but this breaks both the strict weak ordering requirements that are
required for the "Compare" requirement for things like
std::map/set/priority_queue.

For example:

    a = {.foo=1, .bar=3}
    b = {.foo=3, .bar=1}

does not have an ordering over a and b (both `a < b` and `b < a` are
satisfied at the same time).

This needs to be instead something like:

    foo < other.foo or (foo == other.foo and bar < other.bar)

but that's a bit clunkier, and it is easier to use std::tie for tuple's
built-in < comparison which does the right thing:

    std::tie(foo, bar) < std::tie(other.foo, other.bar)

(Initially I noticed this in SockAddr/sockaddr_in6, but upon further
investigation this extends to the major of multi-field `operator<`'s.)

This fixes it by using std::tie (or something similar) everywhere we are
doing multi-field inequalities.
2022-10-13 16:29:13 -03:00
..
iwp.cpp standardize include format and pragma once 2021-03-09 19:01:41 -05:00
iwp.hpp standardize include format and pragma once 2021-03-09 19:01:41 -05:00
linklayer.cpp Fix multi-field < ordering 2022-10-13 16:29:13 -03:00
linklayer.hpp Fix multi-field < ordering 2022-10-13 16:29:13 -03:00
message_buffer.cpp propagate link layer message priority to link layer so it can order retransmissions with that in mind 2022-05-02 15:27:07 -04:00
message_buffer.hpp Fix multi-field < ordering 2022-10-13 16:29:13 -03:00
session.cpp Replace logging with oxen-logger 2022-07-15 22:17:59 -03:00
session.hpp convert priority queues 2022-05-02 15:27:08 -04:00