mirror of
https://github.com/BlackMATov/flat.hpp.git
synced 2025-12-13 01:36:27 +07:00
EBO for multiset and multimap
This commit is contained in:
@@ -70,6 +70,16 @@ namespace
|
||||
return !(l == r);
|
||||
}
|
||||
|
||||
template < typename T >
|
||||
class dummy_less {
|
||||
public:
|
||||
dummy_less(int i) : i(i) {}
|
||||
bool operator()(const T& l, const T& r) const {
|
||||
return l < r;
|
||||
}
|
||||
int i = 0;
|
||||
};
|
||||
|
||||
template < typename T >
|
||||
constexpr std::add_const_t<T>& my_as_const(T& t) noexcept {
|
||||
return t;
|
||||
@@ -77,6 +87,14 @@ namespace
|
||||
}
|
||||
|
||||
TEST_CASE("flat_multimap") {
|
||||
SECTION("sizeof") {
|
||||
REQUIRE(sizeof(flat_multimap<int, unsigned>) == sizeof(std::vector<std::pair<int, unsigned>>));
|
||||
|
||||
struct vc : flat_multimap<int, unsigned>::value_compare {
|
||||
int i;
|
||||
};
|
||||
REQUIRE(sizeof(vc) == sizeof(int));
|
||||
}
|
||||
SECTION("types") {
|
||||
using map_t = flat_multimap<int, unsigned>;
|
||||
|
||||
@@ -418,6 +436,16 @@ TEST_CASE("flat_multimap") {
|
||||
REQUIRE(my_as_const(s0).key_comp().i == 42);
|
||||
REQUIRE(my_as_const(s0).value_comp()({2,50},{4,20}));
|
||||
}
|
||||
SECTION("custom_less") {
|
||||
using map_t = flat_multimap<int, unsigned, dummy_less<int>>;
|
||||
auto s0 = map_t(dummy_less<int>(42));
|
||||
auto s1 = map_t(dummy_less<int>(21));
|
||||
REQUIRE(s0.key_comp().i == 42);
|
||||
REQUIRE(s1.key_comp().i == 21);
|
||||
s0.swap(s1);
|
||||
REQUIRE(s0.key_comp().i == 21);
|
||||
REQUIRE(s1.key_comp().i == 42);
|
||||
}
|
||||
SECTION("operators") {
|
||||
using map_t = flat_multimap<int, unsigned>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user