From 8e9b7cf2598773013db2b6e7d3b8d9d6dd4418da Mon Sep 17 00:00:00 2001 From: Christian Mazakas Date: Tue, 4 Oct 2022 14:51:45 -0700 Subject: [PATCH] Add move semantics to FOA containers --- .../boost/unordered/unordered_flat_map.hpp | 23 +++++++++++++++++++ .../boost/unordered/unordered_flat_set.hpp | 23 +++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/include/boost/unordered/unordered_flat_map.hpp b/include/boost/unordered/unordered_flat_map.hpp index c7b0b3ec..2add8d34 100644 --- a/include/boost/unordered/unordered_flat_map.hpp +++ b/include/boost/unordered/unordered_flat_map.hpp @@ -89,6 +89,19 @@ namespace boost { { } + unordered_flat_map(unordered_flat_map&& other) + noexcept(std::is_nothrow_move_constructible::value&& + std::is_nothrow_move_constructible::value&& + std::is_nothrow_move_constructible::value) + : table_(std::move(other.table_)) + { + } + + unordered_flat_map(unordered_flat_map&& other, allocator_type const& al) + : table_(std::move(other.table_), al) + { + } + unordered_flat_map(std::initializer_list ilist, size_type n = 0, hasher const& h = hasher(), key_equal const& pred = key_equal(), @@ -105,6 +118,16 @@ namespace boost { return *this; } + unordered_flat_map& operator=(unordered_flat_map&& other) + noexcept(std::allocator_traits::is_always_equal::value&& + std::is_nothrow_move_assignable::value&& + std::is_nothrow_move_assignable::value) + { + table_ = std::move(other.table_); + return *this; + } + + allocator_type get_allocator() const noexcept { return table_.get_allocator(); diff --git a/include/boost/unordered/unordered_flat_set.hpp b/include/boost/unordered/unordered_flat_set.hpp index b1caed49..1ac629f0 100644 --- a/include/boost/unordered/unordered_flat_set.hpp +++ b/include/boost/unordered/unordered_flat_set.hpp @@ -88,6 +88,19 @@ namespace boost { { } + unordered_flat_set(unordered_flat_set&& other) + noexcept(std::is_nothrow_move_constructible::value&& + std::is_nothrow_move_constructible::value&& + std::is_nothrow_move_constructible::value) + : table_(std::move(other.table_)) + { + } + + unordered_flat_set(unordered_flat_set&& other, allocator_type const& al) + : table_(std::move(other.table_), al) + { + } + unordered_flat_set(std::initializer_list ilist, size_type n = 0, hasher const& h = hasher(), key_equal const& pred = key_equal(), @@ -104,6 +117,16 @@ namespace boost { return *this; } + unordered_flat_set& operator=(unordered_flat_set&& other) + noexcept(std::allocator_traits::is_always_equal::value&& + std::is_nothrow_move_assignable::value&& + std::is_nothrow_move_assignable::value) + { + table_ = std::move(other.table_); + return *this; + } + + allocator_type get_allocator() const noexcept { return table_.get_allocator();