mirror of
https://github.com/BlackMATov/flat.hpp.git
synced 2025-12-13 17:48:14 +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_multiset") {
|
||||
SECTION("sizeof") {
|
||||
REQUIRE(sizeof(flat_multiset<int>) == sizeof(std::vector<int>));
|
||||
|
||||
struct vc : flat_multiset<int>::value_compare {
|
||||
int i;
|
||||
};
|
||||
REQUIRE(sizeof(vc) == sizeof(int));
|
||||
}
|
||||
SECTION("types") {
|
||||
using set_t = flat_multiset<int>;
|
||||
|
||||
@@ -392,6 +410,16 @@ TEST_CASE("flat_multiset") {
|
||||
REQUIRE(my_as_const(s0).key_comp().i == 42);
|
||||
REQUIRE(my_as_const(s0).value_comp().i == 42);
|
||||
}
|
||||
SECTION("custom_less") {
|
||||
using set_t = flat_multiset<int, dummy_less<int>>;
|
||||
auto s0 = set_t(dummy_less<int>(42));
|
||||
auto s1 = set_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 set_t = flat_multiset<int>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user