mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
flat_map: add value_comp()
This commit is contained in:
parent
e37fdb240a
commit
f520599ab7
@ -611,6 +611,21 @@ public:
|
||||
return comp();
|
||||
}
|
||||
|
||||
class value_compare {
|
||||
friend class flat_map;
|
||||
protected:
|
||||
Compare c;
|
||||
value_compare(Compare c_in) : c(c_in) {}
|
||||
public:
|
||||
bool operator()(const value_type &lhs, const value_type &rhs) {
|
||||
return c(lhs.first, rhs.first);
|
||||
}
|
||||
};
|
||||
|
||||
value_compare value_comp() const {
|
||||
return value_compare(comp());
|
||||
}
|
||||
|
||||
// Operators.
|
||||
|
||||
bool operator==(const flat_map &a) const {
|
||||
|
@ -211,6 +211,7 @@ TEST(flat_map, custom_compare) {
|
||||
ASSERT_EQ(10, f.rbegin()->second);
|
||||
|
||||
ASSERT_TRUE(flat_map_is_sorted(f));
|
||||
ASSERT_TRUE(std::is_sorted(f.begin(), f.end(), f.value_comp()));
|
||||
ASSERT_TRUE(flat_map_is_sorted_cmp(f, std::greater<u32>()));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user