diff --git a/headers/flat_hpp/flat_map.hpp b/headers/flat_hpp/flat_map.hpp index cca641a..90306f9 100644 --- a/headers/flat_hpp/flat_map.hpp +++ b/headers/flat_hpp/flat_map.hpp @@ -135,6 +135,14 @@ namespace flat_hpp insert(ilist); } + flat_map(flat_map&& other, const Allocator& a) + : data_(std::move(other.data_), a) + , compare_(std::move(other.compare_)) {} + + flat_map(const flat_map& other, const Allocator& a) + : data_(other.data_, a) + , compare_(other.compare_) {} + flat_map(flat_map&& other) = default; flat_map(const flat_map& other) = default; diff --git a/headers/flat_hpp/flat_set.hpp b/headers/flat_hpp/flat_set.hpp index ffec69e..7b0dd73 100644 --- a/headers/flat_hpp/flat_set.hpp +++ b/headers/flat_hpp/flat_set.hpp @@ -104,6 +104,14 @@ namespace flat_hpp insert(ilist); } + flat_set(flat_set&& other, const Allocator& a) + : data_(std::move(other.data_), a) + , compare_(std::move(other.compare_)) {} + + flat_set(const flat_set& other, const Allocator& a) + : data_(other.data_, a) + , compare_(other.compare_) {} + flat_set(flat_set&& other) = default; flat_set(const flat_set& other) = default; diff --git a/untests/flat_map_tests.cpp b/untests/flat_map_tests.cpp index b8b56ef..2d6b976 100644 --- a/untests/flat_map_tests.cpp +++ b/untests/flat_map_tests.cpp @@ -177,6 +177,13 @@ TEST_CASE("flat_map") { auto s2 = std::move(s1); REQUIRE(s1.empty()); REQUIRE(s2 == map_t{{0,1}, {1,2}}); + auto s3 = map_t(s2, alloc_t(42)); + REQUIRE(s2 == s3); + REQUIRE(s2.get_allocator().i == 0); + REQUIRE(s3.get_allocator().i == 42); + auto s4 = map_t(std::move(s3), alloc_t(21)); + REQUIRE(s3.empty()); + REQUIRE(s4 == map_t{{0,1}, {1,2}}); } { diff --git a/untests/flat_set_tests.cpp b/untests/flat_set_tests.cpp index bbc0435..ea6b6af 100644 --- a/untests/flat_set_tests.cpp +++ b/untests/flat_set_tests.cpp @@ -161,6 +161,13 @@ TEST_CASE("flat_set") { auto s2 = std::move(s1); REQUIRE(s1.empty()); REQUIRE(s2 == set_t{0,1,2}); + auto s3 = set_t(s2, alloc_t(42)); + REQUIRE(s2 == s3); + REQUIRE(s2.get_allocator().i == 0); + REQUIRE(s3.get_allocator().i == 42); + auto s4 = set_t(std::move(s3), alloc_t(21)); + REQUIRE(s3.empty()); + REQUIRE(s4 == set_t{0,1,2}); } {