heterogeneous find, lower_bound and upper_bound

This commit is contained in:
2019-05-27 16:51:01 +07:00
parent 8124786734
commit 00d676f998
12 changed files with 419 additions and 83 deletions

View File

@@ -9,6 +9,9 @@
#include <deque>
#include <string>
#include <string_view>
#include <flat.hpp/flat_multimap.hpp>
using namespace flat_hpp;
@@ -54,6 +57,10 @@ namespace
}
TEST_CASE("flat_multimap") {
SECTION("detail") {
STATIC_REQUIRE(detail::is_transparent<std::less<>, int>::value);
STATIC_REQUIRE_FALSE(detail::is_transparent<std::less<int>, int>::value);
}
SECTION("sizeof") {
REQUIRE(sizeof(flat_multimap<int, unsigned>) == sizeof(std::vector<std::pair<int, unsigned>>));
@@ -405,6 +412,13 @@ TEST_CASE("flat_multimap") {
REQUIRE(my_as_const(s0).lower_bound(-1) == s0.cbegin());
REQUIRE(my_as_const(s0).lower_bound(7) == s0.cbegin() + 4);
}
{
flat_multimap<std::string, int, std::less<>> s0{{"hello", 42}, {"world", 84}};
REQUIRE(s0.find(std::string_view("hello")) == s0.begin());
REQUIRE(my_as_const(s0).find(std::string_view("world")) == s0.begin() + 1);
REQUIRE(s0.find(std::string_view("42")) == s0.end());
REQUIRE(my_as_const(s0).find(std::string_view("42")) == s0.cend());
}
}
SECTION("observers") {
struct my_less {