Skip to content

Commit c04e76d

Browse files
add < operator to UVarint (#57)
Signed-off-by: Alexey-N-Chernyshov <[email protected]>
1 parent f77b54b commit c04e76d

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

include/libp2p/multi/uvarint.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ namespace libp2p::multi {
6767

6868
bool operator==(const UVarint& r) const;
6969
bool operator!=(const UVarint& r) const;
70+
bool operator<(const UVarint& r) const;
7071

7172
/**
7273
* @return the number of bytes currently stored in a varint

src/multi/uvarint.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ namespace libp2p::multi {
7676
return !(*this == r);
7777
}
7878

79+
bool UVarint::operator<(const UVarint &r) const {
80+
return toUInt64() < r.toUInt64();
81+
}
82+
7983
size_t UVarint::calculateSize(gsl::span<const uint8_t> varint_bytes) {
8084
size_t size = 0;
8185
size_t shift = 0;

0 commit comments

Comments
 (0)