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_multiset.hpp>
using namespace flat_hpp;
@@ -54,6 +57,10 @@ namespace
}
TEST_CASE("flat_multiset") {
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_multiset<int>) == sizeof(std::vector<int>));
@@ -381,6 +388,13 @@ TEST_CASE("flat_multiset") {
REQUIRE(my_as_const(s0).lower_bound(-1) == s0.cbegin());
REQUIRE(my_as_const(s0).lower_bound(7) == s0.cbegin() + 4);
}
{
flat_multiset<std::string, std::less<>> s0{"hello", "world"};
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 {